mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 22:56:11 +03:00
bundler: fix bugs (#1141)
swc_bundler: - Handle aliased imports of reexports correctly. (#1138) - Fix import deglobber. (#1139)
This commit is contained in:
parent
aa9555865b
commit
c127cb2b48
@ -6,7 +6,7 @@ edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_bundler"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.9.1"
|
||||
version = "0.9.2"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
[features]
|
||||
|
@ -107,7 +107,12 @@ pub(super) struct Plan {
|
||||
|
||||
impl Plan {
|
||||
pub fn entry_as_circular(&self, entry: ModuleId) -> Option<&CircularPlan> {
|
||||
self.circular.get(&entry)
|
||||
let plan = self.circular.get(&entry)?;
|
||||
if plan.chunks.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(plan)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,6 +299,8 @@ impl Fold for ExportRenamer<'_> {
|
||||
(s.orig.sym.clone(), self.dep_ctxt),
|
||||
s.orig.to_id(),
|
||||
);
|
||||
self.remark_map
|
||||
.insert((id.0.clone(), ctxt), self.dep_ctxt);
|
||||
|
||||
Some((id.0, ctxt))
|
||||
}
|
||||
|
@ -370,7 +370,8 @@ where
|
||||
match s {
|
||||
ImportSpecifier::Namespace(n) => {
|
||||
return i.sym == n.local.sym
|
||||
&& i.span.ctxt() == self.module_ctxt
|
||||
&& (i.span.ctxt == self.module_ctxt
|
||||
|| i.span.ctxt == n.local.span.ctxt)
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
7
spack/tests/pass/issue-1138/example-1/input/.swcrc
Normal file
7
spack/tests/pass/issue-1138/example-1/input/.swcrc
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "typescript"
|
||||
}
|
||||
}
|
||||
}
|
1
spack/tests/pass/issue-1138/example-1/input/a.ts
Normal file
1
spack/tests/pass/issue-1138/example-1/input/a.ts
Normal file
@ -0,0 +1 @@
|
||||
export const a = "a";
|
7
spack/tests/pass/issue-1138/example-1/input/entry.js
Normal file
7
spack/tests/pass/issue-1138/example-1/input/entry.js
Normal file
@ -0,0 +1,7 @@
|
||||
import { a as defaultA } from "./l.ts";
|
||||
|
||||
const o: { a?: string } = {};
|
||||
|
||||
const { a = defaultA } = o;
|
||||
|
||||
console.log(a);
|
1
spack/tests/pass/issue-1138/example-1/input/l.ts
Normal file
1
spack/tests/pass/issue-1138/example-1/input/l.ts
Normal file
@ -0,0 +1 @@
|
||||
export { a } from "./a.ts";
|
6
spack/tests/pass/issue-1138/example-1/output/entry.js
Normal file
6
spack/tests/pass/issue-1138/example-1/output/entry.js
Normal file
@ -0,0 +1,6 @@
|
||||
var a = "a";
|
||||
const defaultA = a;
|
||||
var o = {
|
||||
};
|
||||
var _a = o.a, a1 = _a === void 0 ? defaultA : _a;
|
||||
console.log(a1);
|
7
spack/tests/pass/issue-1138/example-2/input/.swcrc
Normal file
7
spack/tests/pass/issue-1138/example-2/input/.swcrc
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "typescript"
|
||||
}
|
||||
}
|
||||
}
|
1
spack/tests/pass/issue-1138/example-2/input/a.ts
Normal file
1
spack/tests/pass/issue-1138/example-2/input/a.ts
Normal file
@ -0,0 +1 @@
|
||||
export const defaultA = "a";
|
7
spack/tests/pass/issue-1138/example-2/input/entry.js
Normal file
7
spack/tests/pass/issue-1138/example-2/input/entry.js
Normal file
@ -0,0 +1,7 @@
|
||||
import { defaultA } from "./l.ts";
|
||||
|
||||
const o: { a?: string } = {};
|
||||
|
||||
const { a = defaultA } = o;
|
||||
|
||||
console.log(a);
|
1
spack/tests/pass/issue-1138/example-2/input/l.ts
Normal file
1
spack/tests/pass/issue-1138/example-2/input/l.ts
Normal file
@ -0,0 +1 @@
|
||||
export { defaultA } from "./a.ts";
|
6
spack/tests/pass/issue-1138/example-2/output/entry.js
Normal file
6
spack/tests/pass/issue-1138/example-2/output/entry.js
Normal file
@ -0,0 +1,6 @@
|
||||
var defaultA = "a";
|
||||
const defaultA1 = defaultA;
|
||||
var o = {
|
||||
};
|
||||
var _a = o.a, a = _a === void 0 ? defaultA1 : _a;
|
||||
console.log(a);
|
7
spack/tests/pass/issue-1139/example-1/input/a.js
Normal file
7
spack/tests/pass/issue-1139/example-1/input/a.js
Normal file
@ -0,0 +1,7 @@
|
||||
import * as circular1 from "./entry";
|
||||
|
||||
export function f2() {
|
||||
console.log("f2");
|
||||
}
|
||||
|
||||
circular1.f1();
|
7
spack/tests/pass/issue-1139/example-1/input/entry.js
Normal file
7
spack/tests/pass/issue-1139/example-1/input/entry.js
Normal file
@ -0,0 +1,7 @@
|
||||
import * as circular2 from "./a";
|
||||
|
||||
export function f1() {
|
||||
console.log("f1");
|
||||
}
|
||||
|
||||
circular2.f2();
|
8
spack/tests/pass/issue-1139/example-1/output/entry.js
Normal file
8
spack/tests/pass/issue-1139/example-1/output/entry.js
Normal file
@ -0,0 +1,8 @@
|
||||
export function f1() {
|
||||
console.log("f1");
|
||||
}
|
||||
f2();
|
||||
function f2() {
|
||||
console.log("f2");
|
||||
}
|
||||
f1();
|
7
spack/tests/pass/issue-1139/example-2/input/a.js
Normal file
7
spack/tests/pass/issue-1139/example-2/input/a.js
Normal file
@ -0,0 +1,7 @@
|
||||
import * as circular2 from "./b";
|
||||
|
||||
export function f1() {
|
||||
console.log("f1");
|
||||
}
|
||||
|
||||
circular2.f2();
|
7
spack/tests/pass/issue-1139/example-2/input/b.js
Normal file
7
spack/tests/pass/issue-1139/example-2/input/b.js
Normal file
@ -0,0 +1,7 @@
|
||||
import * as circular1 from "./a";
|
||||
|
||||
export function f2() {
|
||||
console.log("f2");
|
||||
}
|
||||
|
||||
circular1.f1();
|
1
spack/tests/pass/issue-1139/example-2/input/entry.js
Normal file
1
spack/tests/pass/issue-1139/example-2/input/entry.js
Normal file
@ -0,0 +1 @@
|
||||
import './a';
|
8
spack/tests/pass/issue-1139/example-2/output/entry.js
Normal file
8
spack/tests/pass/issue-1139/example-2/output/entry.js
Normal file
@ -0,0 +1,8 @@
|
||||
function f1() {
|
||||
console.log("f1");
|
||||
}
|
||||
f2();
|
||||
function f2() {
|
||||
console.log("f2");
|
||||
}
|
||||
f1();
|
Loading…
Reference in New Issue
Block a user