Skip to content

Commit

Permalink
fix: transfrom default export error when do optimizePackageImports (#832
Browse files Browse the repository at this point in the history
)

Co-authored-by: zp365238 <[email protected]>
  • Loading branch information
zhangpanweb and zp365238 authored Jan 2, 2024
1 parent 6092d45 commit 3431c48
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@ fn parse_barrel_file(
// (source, orig, exported)
for (k, v) in more_export_infos {
if is_barrel_file {
export_infos.insert(k, (v.0.clone(), v.2.clone(), v.2));
export_infos.insert(k, (v.0.clone(), v.1.clone(), v.2));
} else {
export_infos.insert(k, (path.clone(), v.1.clone(), v.1));
export_infos.insert(k, (path.clone(), v.1.clone(), v.2));
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion e2e/fixtures/optimize-package-imports/expect.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ assert(content.includes(`var _a3exportfrom = __mako_require__("node_modules/a-si
assert(content.includes(`var _a4 = __mako_require__("node_modules/a-side-effects-false/a4.js");`), "should include a4.js");
assert(content.includes(`_a4.a41`), "should include _a4.a41");
assert(content.includes(`var _a5 = __mako_require__("node_modules/a-side-effects-false/a5.js");`), "should include a5.js");
assert(content.includes(`var _a61 = __mako_require__("node_modules/a-side-effects-false/a61.js");`), "should include a61.js");
assert(content.includes(`var _a61 = _interop_require_default._(__mako_require__("node_modules/a-side-effects-false/a61.js"));`), "should include a61.js");

assert(content.includes(`var _bsideeffectstrue = __mako_require__("node_modules/b-side-effects-true/index.js");`), "should include a-side-effects-true/index.js (barrel file) but sideEffects: true");

// 判断 barrel_file 时忽略 side_effects:false 且有 var x = a.b 的场景
assert(content.includes(`var _aaa = __mako_require__("node_modules/d-side-effects-false/aaa.js");`), "should include d-side-effects-true/aaa.js (barrel file)");


// TODO:
// [x] 1\ export * as foo from './foo';
// 2\ alias
Expand Down

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

0 comments on commit 3431c48

Please sign in to comment.