Skip to content

Commit

Permalink
fix(commonjs): resolve export exports not found (#1363)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert authored Dec 15, 2022
1 parent 7b62557 commit 39a39d7
Show file tree
Hide file tree
Showing 5 changed files with 256 additions and 99 deletions.
11 changes: 8 additions & 3 deletions packages/commonjs/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,15 @@ export default function commonjs(options = {}) {
}

if (isWrappedId(id, MODULE_SUFFIX)) {
const name = getName(unwrapId(id, MODULE_SUFFIX));
const module = getName(unwrapId(id, MODULE_SUFFIX));
const moduleExports = `${module}Exports`;
return {
code: `var ${name} = {exports: {}}; export {${name} as __module}`,
syntheticNamedExports: '__module',
code: `var ${moduleExports} = {};
var ${module} = {
get exports(){ return ${moduleExports}; },
set exports(v){ ${moduleExports} = v; },
};
export {${module} as __module, ${moduleExports} as exports}`,
meta: { commonjs: { isCommonJS: false } }
};
}
Expand Down
Loading

0 comments on commit 39a39d7

Please sign in to comment.