Skip to content

Commit d5921cd

Browse files
authored
Merge pull request #5092 from Tyriar/tyriar/esbuild3
Add support for ESM via esbuild
2 parents 5b5e262 + f341d0a commit d5921cd

File tree

94 files changed

+926
-348
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+926
-348
lines changed

.eslintrc.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,13 @@
4545
"addons/*/src/third-party/*.ts",
4646
"out/*",
4747
"out-test/*",
48+
"out-esbuild/*",
49+
"out-esbuild-test/*",
4850
"**/inwasm-sdks/*",
4951
"**/typings/*.d.ts",
5052
"**/node_modules",
51-
"**/*.js"
53+
"**/*.js",
54+
"**/*.mjs"
5255
],
5356
"plugins": [
5457
"@stylistic/ts",

.github/workflows/ci.yml

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,52 @@ jobs:
1919
cache: 'yarn'
2020
- name: Install dependencies
2121
run: yarn --frozen-lockfile
22-
- name: Build
22+
- name: Setup and run tsc
2323
run: yarn setup
24+
- name: Esbuild
25+
run: yarn esbuild
2426
- name: Zip artifacts
2527
run: |
2628
zip -r compressed-build \
29+
./lib/* \
2730
./out/* \
28-
./out-test/* \
31+
./out-*/* \
32+
./addons/addon-attach/lib/* \
2933
./addons/addon-attach/out/* \
30-
./addons/addon-attach/out-test/* \
34+
./addons/addon-attach/out-*/* \
35+
./addons/addon-canvas/lib/* \
3136
./addons/addon-canvas/out/* \
32-
./addons/addon-canvas/out-test/* \
37+
./addons/addon-canvas/out-*/* \
38+
./addons/addon-clipboard/lib/* \
3339
./addons/addon-clipboard/out/* \
34-
./addons/addon-clipboard/out-test/* \
40+
./addons/addon-clipboard/out-*/* \
41+
./addons/addon-fit/lib/* \
3542
./addons/addon-fit/out/* \
36-
./addons/addon-fit/out-test/* \
43+
./addons/addon-fit/out-*/* \
44+
./addons/addon-image/lib/* \
3745
./addons/addon-image/out/* \
38-
./addons/addon-image/out-test/* \
46+
./addons/addon-image/out-*/* \
47+
./addons/addon-ligatures/lib/* \
3948
./addons/addon-ligatures/out/* \
40-
./addons/addon-ligatures/out-test/* \
49+
./addons/addon-ligatures/out-*/* \
50+
./addons/addon-search/lib/* \
4151
./addons/addon-search/out/* \
42-
./addons/addon-search/out-test/* \
52+
./addons/addon-search/out-*/* \
53+
./addons/addon-serialize/lib/* \
4354
./addons/addon-serialize/out/* \
44-
./addons/addon-serialize/out-test/* \
55+
./addons/addon-serialize/out-*/* \
56+
./addons/addon-unicode11/lib/* \
4557
./addons/addon-unicode11/out/* \
46-
./addons/addon-unicode11/out-test/* \
58+
./addons/addon-unicode11/out-*/* \
59+
./addons/addon-unicode-graphemes/lib/* \
4760
./addons/addon-unicode-graphemes/out/* \
48-
./addons/addon-unicode-graphemes/out-test/* \
61+
./addons/addon-unicode-graphemes/out-*/* \
62+
./addons/addon-web-links/lib/* \
4963
./addons/addon-web-links/out/* \
50-
./addons/addon-web-links/out-test/* \
64+
./addons/addon-web-links/out-*/* \
65+
./addons/addon-webgl/lib/* \
5166
./addons/addon-webgl/out/* \
52-
./addons/addon-webgl/out-test/*
67+
./addons/addon-webgl/out-*st/*
5368
- name: Upload artifacts
5469
uses: actions/upload-artifact@v3
5570
with:
@@ -189,7 +204,7 @@ jobs:
189204
fi
190205
ls -R
191206
- name: Build demo
192-
run: yarn build-demo
207+
run: yarn esbuild-demo
193208
- name: Integration tests (core) # Tests use 50% workers to reduce flakiness
194209
run: yarn test-integration-${{ matrix.browser }} --workers=50% --forbid-only --suite=core
195210
- name: Integration tests (addon-attach)

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ node_modules/
44
lib/
55
out/
66
out-test/
7+
out-esbuild/
8+
out-esbuild-test/
79
.nyc_output/
810
Makefile.gyp
911
*.Makefile

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
!lib/**/*.js
1818
!lib/**/*.js.map
1919

20+
!lib/**/*.mjs
21+
!lib/**/*.mjs.map
22+
2023
!lib/**/*.css
2124

2225
# Whitelist - src/

.vscode/settings.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,25 @@
22
"files.associations": {
33
".eslintrc.json.typings": "jsonc"
44
},
5+
// Hide output files from the file explorer, comment this out to see the build output
6+
"files.exclude": {
7+
"**/lib": true,
8+
"**/out": true,
9+
"**/out-*": true,
10+
},
511
"typescript.preferences.importModuleSpecifier": "non-relative",
612
"typescript.preferences.quoteStyle": "single",
713
"mochaExplorer.envPath": ".mocha.env",
814
"mochaExplorer.files": [
915
"out/**/*.test.js",
10-
"addons/**/out/*.test.js"
16+
"addons/**/out/*.test.js",
17+
"out-*/**/*.test.js",
18+
"addons/**/out-*/*.test.js"
1119
],
1220
"mochaExplorer.watch": [
1321
"out/**/*.js",
14-
"addons/**/out/*.js"
22+
"addons/**/out/*.js",
23+
"out-*/**/*.js",
24+
"addons/**/out-*/*.js"
1525
]
1626
}

.vscode/tasks.json

Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,67 +8,74 @@
88
"showReuseMessage": true
99
},
1010
"tasks": [
11+
// Compound tasks
1112
{
12-
"type": "npm",
13-
"script": "test",
14-
"group":{
15-
"kind": "test",
13+
"label": "Development",
14+
"dependsOn": ["demo-server", "tsc", "esbuild", "esbuild-demo"],
15+
"group": {
16+
"kind": "build",
1617
"isDefault": true
17-
},
18-
"problemMatcher": []
18+
}
19+
},
20+
21+
// Demo
22+
{
23+
"label": "demo-server",
24+
"type": "npm",
25+
"script": "start",
26+
"group": "build",
27+
"isBackground": true,
28+
"problemMatcher": [],
29+
"presentation": {
30+
"group": "xterm-demo"
31+
}
1932
},
33+
34+
// Build
2035
{
21-
"label": "watch",
36+
"label": "tsc",
2237
"type": "npm",
23-
"script": "watch",
38+
"script": "tsc-watch",
2439
"group": "build",
2540
"isBackground": true,
2641
"problemMatcher": "$tsc-watch",
2742
"presentation": {
28-
"group": "vscode"
43+
"group": "xterm-build"
2944
}
3045
},
3146
{
32-
"label": "start",
47+
"label": "esbuild",
3348
"type": "npm",
34-
"script": "start",
49+
"script": "esbuild-watch",
3550
"group": "build",
3651
"isBackground": true,
37-
"problemMatcher": [],
52+
"problemMatcher": "$esbuild-watch",
3853
"presentation": {
39-
"group": "vscode"
54+
"group": "xterm-build"
4055
}
4156
},
4257
{
43-
"label": "Start demo",
44-
"dependsOn": ["start", "watch"],
45-
"group": {
46-
"kind": "build",
47-
"isDefault": true
48-
},
58+
"label": "esbuild-demo",
59+
"type": "npm",
60+
"script": "esbuild-demo-watch",
61+
"dependsOn": ["esbuild", "tsc"],
62+
"group": "build",
4963
"isBackground": true,
50-
"problemMatcher": {
51-
"owner": "typescript",
52-
"fileLocation": [
53-
"relative",
54-
"${workspaceFolder}"
55-
],
56-
"pattern": [
57-
{
58-
"regexp": "^([^\\\\s].*)\\\\((\\\\d+,\\\\d+)\\\\):\\\\s*(.*)$",
59-
"file": 1,
60-
"location": 2,
61-
"message": 3
62-
}
63-
],
64-
"background": {
65-
"beginsPattern": "assets by",
66-
"endsPattern": "webpack \\d+\\.\\d+\\.\\d+ compiled successfully"
67-
}
68-
},
64+
"problemMatcher": "$esbuild-watch",
6965
"presentation": {
70-
"group": "vscode"
66+
"group": "xterm-demo"
7167
}
68+
},
69+
70+
// Test
71+
{
72+
"type": "npm",
73+
"script": "test",
74+
"group":{
75+
"kind": "test",
76+
"isDefault": true
77+
},
78+
"problemMatcher": []
7279
}
7380
]
7481
}

CONTRIBUTING.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,45 @@ By contributing code to xterm.js you:
6060
### Test coverage
6161

6262
One area that always needs attention is improving out unit test coverage, you can view the code coverage report on [Azure Pipelines](https://dev.azure.com/xtermjs/xterm.js/_build/latest?definitionId=3) by clicking the Code Coverage tab.
63+
64+
## Testing
65+
66+
### Unit tests
67+
68+
Unit tests are run with `yarn test-unit`:
69+
70+
```sh
71+
# All unit tests
72+
yarn test-unit
73+
74+
# Absolute file path
75+
yarn test-unit out-esbuild/browser/Terminal.test.js
76+
77+
# Filter by wildcard
78+
yarn test-unit out-esbuild/**/Terminal.test.js
79+
80+
# Specific addon unit tests tests
81+
yarn test-unit addons/addon-image/out-esbuild/*.test.js
82+
83+
# Multiple files
84+
yarn test-unit out-esbuild/**/Terminal.test.js out-esbuild/**/InputHandler.test.js
85+
```
86+
87+
These use mocha to run all `.test.js` files within the esbuild output (`out-esbuild/`).
88+
89+
### Integration tests
90+
91+
Integration tests are run with `yarn test-integration`:
92+
93+
```sh
94+
# All integration tests
95+
yarn test-integration
96+
97+
# Core integration tests
98+
yarn test-integration --suite=core
99+
100+
# Specific addon integration tests
101+
yarn test-integration --suite=addon-search
102+
```
103+
104+
These use `@playwright/test` to run all tests within the esbuild test output (`out-esbuild-test/`).

addons/addon-attach/.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
!lib/**/*.js
99
!lib/**/*.js.map
1010

11+
!lib/**/*.mjs
12+
!lib/**/*.mjs.map
13+
1114
!lib/**/*.css
1215

1316
# Whitelist - src/

addons/addon-attach/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"url": "https://xtermjs.org/"
77
},
88
"main": "lib/addon-attach.js",
9+
"module": "lib/addon-attach.mjs",
910
"types": "typings/addon-attach.d.ts",
1011
"repository": "https://github.com/xtermjs/xterm.js/tree/master/addons/addon-attach",
1112
"license": "MIT",
@@ -19,7 +20,7 @@
1920
"prepackage": "npm run build",
2021
"package": "../../node_modules/.bin/webpack",
2122
"prepublishOnly": "npm run package",
22-
"start-server-only": "node ../../demo/start-server-only"
23+
"start": "node ../../demo/start"
2324
},
2425
"peerDependencies": {
2526
"@xterm/xterm": "^5.0.0"

addons/addon-attach/test/AttachAddon.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import WebSocket = require('ws');
77

88
import test from '@playwright/test';
9-
import { ITestContext, createTestContext, openTerminal, pollFor, timeout } from '../../../out-test/playwright/TestUtils';
9+
import { ITestContext, createTestContext, openTerminal, pollFor, timeout } from '../../../test/playwright/TestUtils';
1010

1111
let ctx: ITestContext;
1212
test.beforeAll(async ({ browser }) => {

addons/addon-attach/test/playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const config: PlaywrightTestConfig = {
2626
],
2727
reporter: 'list',
2828
webServer: {
29-
command: 'npm run start-server-only',
29+
command: 'npm run start',
3030
port: 3000,
3131
timeout: 120000,
3232
reuseExistingServer: !process.env.CI

addons/addon-attach/test/tsconfig.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
},
2121
"strict": true,
2222
"types": [
23-
"../../../node_modules/@types/node",
24-
"../../../out-test/playwright/TestUtils"
23+
"../../../node_modules/@types/node"
2524
]
2625
},
2726
"include": [
@@ -34,6 +33,9 @@
3433
},
3534
{
3635
"path": "../../../src/browser"
36+
},
37+
{
38+
"path": "../../../test/playwright"
3739
}
3840
]
3941
}

addons/addon-canvas/.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
!lib/**/*.js
99
!lib/**/*.js.map
1010

11+
!lib/**/*.mjs
12+
!lib/**/*.mjs.map
13+
1114
!lib/**/*.css
1215

1316
# Whitelist - src/

addons/addon-canvas/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"url": "https://xtermjs.org/"
77
},
88
"main": "lib/addon-canvas.js",
9+
"module": "lib/addon-canvas.mjs",
910
"types": "typings/addon-canvas.d.ts",
1011
"repository": "https://github.com/xtermjs/xterm.js/tree/master/addons/addon-canvas",
1112
"license": "MIT",
@@ -20,7 +21,7 @@
2021
"prepackage": "npm run build",
2122
"package": "../../node_modules/.bin/webpack",
2223
"prepublishOnly": "npm run package",
23-
"start-server-only": "node ../../demo/start-server-only"
24+
"start": "node ../../demo/start"
2425
},
2526
"peerDependencies": {
2627
"@xterm/xterm": "^5.0.0"

0 commit comments

Comments
 (0)