-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
155 lines (104 loc) Β· 5.05 KB
/
e2e-parcel-workflow.yml
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#
on:
schedule:
- cron: '0 */4 * * *'
push:
branches:
- master
pull_request:
paths:
- .github/actions/prepare/action.yml
- .github/workflows/e2e-parcel-workflow.yml
- scripts/e2e-setup-ci.sh
name: 'E2E Parcel'
jobs:
chore:
name: 'Validating Parcel'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- name: 'Running the integration test'
run: |
source scripts/e2e-setup-ci.sh
yarn init -p
yarn add -D parcel@nightly lodash @babel/core
# See https://github.com/parcel-bundler/parcel/issues/9114
echo "packageExtensions:
\"@parcel/fs@*\":
dependencies:
\"@parcel/core\": '*'" > .yarnrc.yml
# JavaScript
echo "import _ from 'lodash';function printHello() { console.log(_.join(['Hello', 'JS'], ' '))}; printHello();" | tee index.js
yarn parcel build index.js
[[ "$(node dist/index.js)" = "Hello JS" ]]
rm -rf dist index.js
# TypeScript (Babel)
echo "import * as _ from 'lodash';function printHello() { console.log(_.join(['Hello', 'TS'], ' '))}; printHello();" | tee index.ts
yarn parcel build index.ts
[[ "$(node dist/index.js)" = "Hello TS" ]]
rm -rf dist index.ts
# TypeScript (tsc)
yarn add -D @parcel/core@nightly @parcel/config-default@nightly @parcel/validator-typescript@nightly @types/lodash typescript
echo "{\"extends\": \"@parcel/config-default\", \"validators\": {\"*.{ts,tsx}\": [\"@parcel/validator-typescript\"]}}" | tee .parcelrc
echo "{\"compilerOptions\": { \"noImplicitAny\": true, \"removeComments\": true, \"preserveConstEnums\": true, \"sourceMap\": true}, \"include\": [\"index.ts\"]}" | tee tsconfig.json
echo "import * as _ from 'lodash';function printHello() { console.log(_.join(['Hello', 'TS'], ' '))}; printHello();" | tee index.ts
yarn parcel build index.ts
[[ "$(node dist/index.js)" = "Hello TS" ]]
rm -rf dist index.ts tsconfig.json .parcelrc
# Less
yarn add -D bootstrap-less less postcss @parcel/optimizer-cssnano@nightly @parcel/packager-css@nightly @parcel/transformer-css@nightly @parcel/transformer-less@nightly @parcel/transformer-postcss@nightly
mkdir src
echo "import './main.less';" | tee src/index.js
echo "@import 'bootstrap-less/bootstrap/index.less';@import './other.less';.box:extend(.hotpink) {width: 200px;height: 200px;}" | tee src/main.less
echo ".hotpink {background: hotpink;}" | tee src/other.less
yarn parcel build src/index.js
ls dist | grep "index.css"
rm -rf dist src
# Yaml
yarn add @parcel/transformer-yaml@nightly
echo "import data from './data.yaml';console.log(data.berry.works.with[0]);" | tee index.js
echo "berry: {works: {with: [Parcel]}}" | tee data.yaml
yarn parcel build index.js
[[ "$(node dist/index.js)" = "Parcel" ]]
rm -rf dist index.js data.yaml
# MDX
yarn add react react-dom react-select @mdx-js/mdx @mdx-js/react@^1 @parcel/transformer-mdx@nightly
echo "import page from './page.mdx'; console.log('MDX Built');" | tee index.js
cat > page.mdx <<EOT
import Select from 'react-select';
# Hello, *world*!
<div style={{ padding: '20px', backgroundColor: 'tomato' }}>
<h3>This is JSX</h3>
</div>
<Select />
EOT
yarn parcel build index.js
[[ "$(node dist/index.js)" = "MDX Built" ]]
rm -rf dist index.js page.mdx
# Assets
echo "import 'url:./text.txt';" | tee index.js
echo "Hello World" | tee text.txt
yarn parcel build index.js
ls dist | grep ".txt"
rm -rf dist index.js text.txt
# Tree-shaking
echo "export function square(x) { return x * x } export function cube(x) { return x * x * x }" | tee math.js
echo "import { cube } from './math.js'; console.log(cube(5));" | tee index.js
yarn parcel build index.js
[[ "$(node dist/index.js)" = "125" ]]
! cat dist/index.js | grep "square"
rm -rf dist index.js math.js
# Multiple entry modules
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 parcel build src/main.js src/otherEntry.js
[[ "$(node dist/main.js)" = "625" ]]
[[ "$(node dist/otherEntry.js)" = "125" ]]
! cat dist/main.js | grep "cube"
! cat dist/otherEntry.js | grep "cube"
rm -rf dist src