Skip to content

Commit df7c5bf

Browse files
kevin940726arcanis
authored andcommitted
Add rollup e2e (#681)
1 parent ec5d2e3 commit df7c5bf

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
on:
2+
schedule:
3+
- cron: '0 */4 * * *'
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
paths:
9+
- .github/workflows/e2e-rollup-workflow.yml
10+
- scripts/e2e-setup-ci.sh
11+
12+
name: 'E2E rollup.js'
13+
jobs:
14+
chore:
15+
name: 'Validating rollup.js'
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@master
20+
21+
- name: 'Use Node.js 10.x'
22+
uses: actions/setup-node@master
23+
with:
24+
node-version: 10.x
25+
26+
- name: 'Build the standard bundle'
27+
run: |
28+
node ./scripts/run-yarn.js build:cli
29+
30+
- name: 'Running the integration test'
31+
run: |
32+
source scripts/e2e-setup-ci.sh
33+
34+
yarn init -p
35+
yarn add -D rollup@^1.29.0
36+
37+
# Tree-shaking
38+
echo "export default { input: 'src/main.js', output: { file: 'dist/bundle.js', format: 'cjs' } };" | tee rollup.config.js
39+
40+
mkdir src
41+
echo "export function square(x) { return x * x } export function cube(x) { return x * x * x }" | tee src/maths.js
42+
echo "import { cube } from './maths.js'; console.log(cube(5));" | tee src/main.js
43+
44+
yarn rollup -c
45+
[[ "$(node dist/bundle.js)" = "125" ]]
46+
cat dist/bundle.js | grep -v "square"
47+
48+
rm -rf dist src
49+
50+
# Multiple entry modules
51+
echo "export default { input: ['src/main.js', 'src/otherEntry.js'], output: { dir: 'dist', format: 'cjs' } };" | tee rollup.config.js
52+
53+
mkdir src
54+
echo "import hyperCube from './hyperCube.js'; console.log(hyperCube(5));" | tee src/main.js
55+
echo "import cube from './cube.js'; console.log(cube(5));" | tee src/otherEntry.js
56+
echo "import square from './square.js'; export default function cube(x) { return square(x) * x; }" | tee src/cube.js
57+
echo "import cube from './cube.js'; export default function hyperCube(x) { return cube(x) * x; }" | tee src/hyperCube.js
58+
echo "export default function square(x) { return x * x; }" | tee src/square.js
59+
60+
yarn rollup -c
61+
[[ "$(node dist/main.js)" = "625" ]]
62+
[[ "$(node dist/otherEntry.js)" = "125" ]]
63+
ls dist | grep "cube"
64+
65+
rm -rf dist src
66+
67+
# With NPM packages
68+
yarn add the-answer@^1.0.0
69+
yarn add -D @rollup/plugin-node-resolve@^7.0.0
70+
71+
echo "import resolve from '@rollup/plugin-node-resolve'; export default { input: 'src/main.js', output: { file: 'dist/bundle.js', format: 'cjs' }, plugins: [resolve()]};" | tee rollup.config.js
72+
73+
mkdir src
74+
echo "import answer from 'the-answer'; console.log('the answer is ' + answer);" | tee src/main.js
75+
76+
yarn rollup -c
77+
[[ "$(node dist/bundle.js)" = "the answer is 42" ]]
78+
79+
rm -rf dist src
80+
81+
# Peer dependencies
82+
yarn add -P lodash
83+
84+
echo "import resolve from '@rollup/plugin-node-resolve'; export default { input: 'src/main.js', output: { file: 'dist/bundle.js', format: 'cjs' }, plugins: [resolve()], external: ['lodash']};" | tee rollup.config.js
85+
86+
mkdir src
87+
echo "import answer from 'the-answer'; import _ from 'lodash';" | tee src/main.js
88+
89+
yarn rollup -c
90+
cat dist/bundle.js | grep -v "lodash"
91+
92+
rm -rf src dist
93+
94+
# Babel
95+
yarn add -D rollup-plugin-babel@^4.3.3 @babel/core@^7.7.7 @babel/preset-env@^7.7.7
96+
97+
echo "import resolve from '@rollup/plugin-node-resolve'; import babel from 'rollup-plugin-babel'; export default { input: 'src/main.js', output: { file: 'dist/bundle.js', format: 'cjs' }, plugins: [resolve(), babel({ exclude: 'node_modules/**' })]};" | tee rollup.config.js
98+
99+
mkdir src
100+
echo '{ "presets": [["@babel/preset-env", { "modules": false }]] }' | tee src/.babelrc
101+
echo "import answer from 'the-answer'; console.log(\`the answer is \${answer}\`);" | tee src/main.js
102+
103+
yarn rollup -c
104+
[[ "$(node dist/bundle.js)" = "the answer is 42" ]]
105+
cat dist/bundle.js | grep -v "console.log(\`"
106+
107+
rm -rf src dist
108+
109+
# rollup-plugin-postcss
110+
yarn add -D rollup-plugin-postcss@^2.0.3
111+
112+
echo "import postcss from 'rollup-plugin-postcss'; export default { input: 'src/main.js', output: { file: 'dist/bundle.js', format: 'cjs' }, plugins: [postcss({ extract: true, modules: true })] }" | tee rollup.config.js
113+
114+
mkdir src
115+
echo "import style from './style.css'; console.log(style);" | tee src/main.js
116+
echo ".app { color: red; }" | tee src/style.css
117+
118+
yarn rollup -c
119+
[[ "$(cat dist/bundle.css)" = ".style_app__3FC6W { color: red; }" ]]
120+
[[ "$(node dist/bundle.js)" = "{ app: 'style_app__3FC6W' }" ]]
121+
122+
rm -rf src dist
123+
124+

0 commit comments

Comments
 (0)