Skip to content

Commit

Permalink
fix: CJS interop rollup option for handling default exports
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenbroekema committed Apr 28, 2023
1 parent 4410075 commit d637cec
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/fuzzy-shoes-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tokens-studio/sd-transforms': patch
---

Use Rollup output.interop for CJS output, to properly handle default exports in our CJS external dependencies.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"devDependencies": {
"@changesets/cli": "^2.26.0",
"@esm-bundle/chai": "^4.3.4-fix.0",
"@rollup/plugin-commonjs": "^24.0.1",
"@rollup/plugin-commonjs": "^24.1.0",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-typescript": "^11.0.0",
"@typescript-eslint/eslint-plugin": "^5.54.0",
Expand Down
4 changes: 4 additions & 0 deletions rollup/cjs.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export default {
format: 'cjs',
preserveModules: true,
entryFileNames: '[name].cjs',
// Ensures that CJS default exports are imported properly (based on __esModule)
// If needed, can switch to 'compat' which checks for .default prop on the default export instead
// see https://rollupjs.org/configuration-options/#output-interop
interop: 'auto',
},
plugins: [nodeResolve(), typescript({ tsconfig: 'tsconfig.build.json', declaration: false })],
};

0 comments on commit d637cec

Please sign in to comment.