Skip to content

Commit 2c0e646

Browse files
authored
test: run tests in ESM mode
1 parent 2534868 commit 2c0e646

File tree

794 files changed

+3163
-2597
lines changed

Some content is hidden

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

794 files changed

+3163
-2597
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
- name: Build monorepo for testing
8888
run: |
8989
npm run prebuild
90-
npm run build:cjs
90+
npm run build:es
9191
- name: Execute tests in monorepo
9292
run: npm run test
9393

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,17 +235,18 @@ All the packages have identical build system and expose build artifacts in ident
235235
After building artifacts, every package will contain five (5) additional directories.
236236
All the build artifacts are polymorphic - they can run in different environments like [Web Browser](https://en.wikipedia.org/wiki/Web_browser), [Node.js](https://nodejs.org/) or [Web Worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API).
237237

238-
**cjs/**
238+
***.cjs**
239239

240-
This directory mirrors the structure of the codebase in `src/`.
241-
Contains ES5 compatible code with [CommonJS](https://en.wikipedia.org/wiki/CommonJS) style imports.
242-
Build fragments in this directory are ideal for [Node.js](https://nodejs.org/) and similar environments.
240+
These files are generated inside `src/` directory.
241+
Contain ES5 compatible code with [CommonJS](https://en.wikipedia.org/wiki/CommonJS) style imports.
242+
These build fragments are ideal for legacy [Node.js](https://nodejs.org/) and similar environments.
243243

244-
**es/**
244+
***.mjs**
245245

246-
This directory mirrors the structure of the codebase in `src/`.
247-
Contains ES5 compatible code with [ES6 imports](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import).
248-
Build fragments in this directory are ideal for bundling with [Webpack](https://webpack.js.org/) or similar bundlers.
246+
These files are generated inside `src/` directory.
247+
Contain ES5 compatible code with [ES6 imports](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import).
248+
These build fragments are ideal for modern [Node.js](https://nodejs.org/),
249+
bundling with [Webpack](https://webpack.js.org/) or similar bundlers.
249250

250251
**dist/**
251252

babel.config.cjs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@ const path = require('node:path');
22

33
module.exports = {
44
babelrcRoots: ['packages/*'],
5-
ignore: [
6-
'**/*.d.ts',
7-
],
5+
ignore: ['**/*.d.ts'],
86
env: {
97
cjs: {
10-
browserslistEnv: "isomorphic-production",
8+
browserslistEnv: 'isomorphic-production',
119
presets: [
1210
[
1311
'@babel/preset-env',
1412
{
1513
debug: false,
16-
modules: "commonjs",
14+
modules: 'commonjs',
1715
loose: true,
1816
useBuiltIns: false,
1917
forceAllTransforms: false,
@@ -25,7 +23,7 @@ module.exports = {
2523
'@babel/preset-typescript',
2624
{
2725
allowDeclareFields: true,
28-
}
26+
},
2927
],
3028
],
3129
plugins: [
@@ -40,12 +38,15 @@ module.exports = {
4038
},
4139
],
4240
process.env.NODE_ENV !== 'test'
43-
? [path.join(__dirname, './scripts/babel-plugin-add-import-extension.cjs'), { extension: 'cjs' }]
44-
: false
41+
? [
42+
path.join(__dirname, './scripts/babel-plugin-add-import-extension.cjs'),
43+
{ extension: 'cjs' },
44+
]
45+
: false,
4546
].filter(Boolean),
4647
},
4748
es: {
48-
browserslistEnv: "isomorphic-production",
49+
browserslistEnv: 'isomorphic-production',
4950
presets: [
5051
[
5152
'@babel/preset-env',
@@ -62,7 +63,7 @@ module.exports = {
6263
'@babel/preset-typescript',
6364
{
6465
allowDeclareFields: true,
65-
}
66+
},
6667
],
6768
],
6869
plugins: [
@@ -77,11 +78,14 @@ module.exports = {
7778
version: '^7.22.15',
7879
},
7980
],
80-
[path.join(__dirname, './scripts/babel-plugin-add-import-extension.cjs'), { extension: 'mjs' }],
81+
[
82+
path.join(__dirname, './scripts/babel-plugin-add-import-extension.cjs'),
83+
{ extension: 'mjs' },
84+
],
8185
],
8286
},
8387
browser: {
84-
browserslistEnv: "browser-production",
88+
browserslistEnv: 'browser-production',
8589
presets: [
8690
[
8791
'@babel/preset-env',
@@ -98,7 +102,7 @@ module.exports = {
98102
'@babel/preset-typescript',
99103
{
100104
allowDeclareFields: true,
101-
}
105+
},
102106
],
103107
],
104108
plugins: [
@@ -112,7 +116,7 @@ module.exports = {
112116
version: '^7.22.15',
113117
},
114118
],
115-
]
119+
],
116120
},
117121
},
118122
};

0 commit comments

Comments
 (0)