File: e2e-rollup-workflow.yml

package info (click to toggle)
node-yarnpkg 4.1.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,828 kB
  • sloc: javascript: 38,953; ansic: 26,035; cpp: 7,247; sh: 2,829; makefile: 724; perl: 493
file content (118 lines) | stat: -rw-r--r-- 4,464 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
on:
  schedule:
  - cron: '0 */4 * * *'
  push:
    branches:
    - master
  pull_request:
    paths:
    - .github/actions/prepare/action.yml
    - .github/workflows/e2e-rollup-workflow.yml
    - scripts/e2e-setup-ci.sh

name: 'E2E Rollup'
jobs:
  chore:
    name: 'Validating Rollup'
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3

    - uses: ./.github/actions/prepare

    - name: 'Running the integration test'
      run: |
        source scripts/e2e-setup-ci.sh

        yarn init -p
        yarn add -D rollup@^1.29.0

        # Tree-shaking
        echo "export default { input: 'src/main.js', output: { file: 'dist/bundle.js', format: 'cjs' } };" | tee rollup.config.js

        mkdir src
        echo "export function square(x) { return x * x } export function cube(x) { return x * x * x }" | tee src/maths.js
        echo "import { cube } from './maths.js'; console.log(cube(5));" | tee src/main.js

        yarn rollup -c
        [[ "$(node dist/bundle.js)" = "125" ]]
        ! cat dist/bundle.js | grep "square"

        rm -rf dist src

        # Multiple entry modules
        echo "export default { input: ['src/main.js', 'src/otherEntry.js'], output: { dir: 'dist', format: 'cjs' } };" | tee rollup.config.js

        mkdir src
        echo "import hyperCube from './hyperCube.js'; console.log(hyperCube(5));" | tee src/main.js
        echo "import cube from './cube.js'; console.log(cube(5));" | tee src/otherEntry.js
        echo "import square from './square.js'; export default function cube(x) { return square(x) * x; }" | tee src/cube.js
        echo "import cube from './cube.js'; export default function hyperCube(x) { return cube(x) * x; }" | tee src/hyperCube.js
        echo "export default function square(x) { return x * x; }" | tee src/square.js

        yarn rollup -c
        [[ "$(node dist/main.js)" = "625" ]]
        [[ "$(node dist/otherEntry.js)" = "125" ]]
        ls dist | grep "cube"

        rm -rf dist src

        # With NPM packages
        yarn add the-answer@^1.0.0
        yarn add -D @rollup/plugin-node-resolve@^7.0.0

        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

        mkdir src
        echo "import answer from 'the-answer'; console.log('the answer is ' + answer);" | tee src/main.js

        yarn rollup -c
        [[ "$(node dist/bundle.js)" = "the answer is 42" ]]

        rm -rf dist src

        # Peer dependencies
        yarn add -P lodash

        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

        mkdir src
        echo "import answer from 'the-answer'; import _ from 'lodash';" | tee src/main.js

        yarn rollup -c
        ! cat dist/bundle.js | grep "lodash"

        rm -rf src dist

        # Babel
        yarn add -D rollup-plugin-babel@^4.3.3 @babel/core@^7.7.7 @babel/preset-env@^7.7.7

        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

        mkdir src
        echo '{ "presets": [["@babel/preset-env", { "modules": false }]] }' | tee src/.babelrc
        echo "import answer from 'the-answer'; console.log(\`the answer is \${answer}\`);" | tee src/main.js

        yarn rollup -c
        [[ "$(node dist/bundle.js)" = "the answer is 42" ]]
        ! cat dist/bundle.js | grep "console.log(\`"

        rm -rf src dist

        # rollup-plugin-postcss
        yarn add -D rollup-plugin-postcss@^2.0.3

        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

        mkdir src
        echo "import style from './style.css'; console.log(style);" | tee src/main.js
        echo ".app { color: red; }" | tee src/style.css

        yarn rollup -c
        [[ "$(cat dist/bundle.css)" = ".style_app__3FC6W { color: red; }" ]]
        [[ "$(node dist/bundle.js)" = "{ app: 'style_app__3FC6W' }" ]]

        rm -rf src dist