Skip to content

Commit

Permalink
Merge pull request #197 from gunsch/webidl-conversions
Browse files Browse the repository at this point in the history
Fixes cjs-to-esm for exports with spaces in their names.
  • Loading branch information
edoardocavazza authored Nov 4, 2024
2 parents b7b1468 + 60e95b1 commit 8e82ec2
Show file tree
Hide file tree
Showing 4 changed files with 470 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changeset/great-rules-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@chialab/cjs-to-esm': patch
'@chialab/esbuild-plugin-commonjs': patch
'@chialab/vite-plugin-commonjs': patch
---

Fixes handling of CJS modules that export identifiers with spaces.
2 changes: 1 addition & 1 deletion packages/cjs-to-esm/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ if (${conditions.join(' && ')}) {
${named.map((name, index) => `__export${index} = module.exports['${name}'];`).join('\n ')}
}`);

helpers.append(`\nexport { ${named.map((name, index) => `__export${index} as ${name}`).join(', ')} }`);
helpers.append(`\nexport { ${named.map((name, index) => `__export${index} as "${name}"`).join(', ')} }`);
}
if (isEsModule) {
if (!isUmd && (hasDefault || named.length === 0)) {
Expand Down
Loading

0 comments on commit 8e82ec2

Please sign in to comment.