Skip to content

Commit

Permalink
fix: make default import work in TS esModuleInterop (#176)
Browse files Browse the repository at this point in the history
Closes: #175
  • Loading branch information
targos committed Nov 4, 2023
1 parent abe3503 commit ac52cb0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export default [
{
input: 'src/index.js',
output: {
esModule: false,
file: 'matrix.js',
format: 'cjs',
exports: 'named',
Expand Down
4 changes: 2 additions & 2 deletions tools/build-esm-facade.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ const exportNames = Object.keys(matrixBuild);

const exports = exportNames.map((name) => {
if (name === 'default') {
return `export default matrix.default;`;
return `export default matrix.default.Matrix ? matrix.default.Matrix : matrix.Matrix;`;
}
return `export const ${name} = matrix.${name};`;
});

await writeFile(
new URL('../matrix.mjs', import.meta.url),
`import matrix from './matrix.js';
`import * as matrix from './matrix.js';
${exports.join('\n')}
`,
Expand Down

0 comments on commit ac52cb0

Please sign in to comment.