Skip to content

Commit e0cfc27

Browse files
committed
fix: restore previous esm build to avoid dual-package hazard
1 parent 0121adb commit e0cfc27

3 files changed

Lines changed: 22 additions & 12 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@
2020
"matrix.js",
2121
"matrix.js.map",
2222
"matrix.mjs",
23-
"matrix.mjs.map",
2423
"matrix.umd.js",
2524
"matrix.umd.js.map",
2625
"src"
2726
],
2827
"scripts": {
28+
"build-esm-facade": "node tools/build-esm-facade.mjs",
2929
"compile": "rollup -c",
3030
"eslint": "eslint src testUtils.js",
3131
"eslint-fix": "npm run eslint -- --fix",
32-
"prepack": "npm run compile",
32+
"prepack": "npm run compile && npm run build-esm-facade",
3333
"prettier": "prettier --check src",
3434
"prettier-write": "prettier --write src",
3535
"test": "npm run test-only && npm run eslint && npm run prettier",

rollup.config.mjs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,6 @@ export default [
1313
},
1414
plugins: [resolve()],
1515
},
16-
{
17-
input: 'src/index.js',
18-
output: {
19-
file: 'matrix.mjs',
20-
format: 'esm',
21-
exports: 'named',
22-
sourcemap: true,
23-
},
24-
plugins: [resolve()],
25-
},
2616
{
2717
input: 'src/index.js',
2818
output: {

tools/build-esm-facade.mjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { writeFile } from 'node:fs/promises';
2+
3+
import matrixBuild from '../matrix.js';
4+
5+
const exportNames = Object.keys(matrixBuild);
6+
7+
const exports = exportNames.map((name) => {
8+
if (name === 'default') {
9+
return `export default matrix.default.Matrix ? matrix.default.Matrix : matrix.Matrix;`;
10+
}
11+
return `export const ${name} = matrix.${name};`;
12+
});
13+
14+
await writeFile(
15+
new URL('../matrix.mjs', import.meta.url),
16+
`import * as matrix from './matrix.js';
17+
18+
${exports.join('\n')}
19+
`,
20+
);

0 commit comments

Comments
 (0)