bundler: fix bugs (#1141)

swc_bundler:
 - Handle aliased imports of reexports correctly. (#1138)
 - Fix import deglobber. (#1139)
This commit is contained in:
강동윤 2020-10-06 13:39:25 +09:00 committed by GitHub
parent aa9555865b
commit c127cb2b48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 100 additions and 3 deletions

View File

@ -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]

View File

@ -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)
}
}

View File

@ -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))
}

View File

@ -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)
}
_ => {}
}

View File

@ -0,0 +1,7 @@
{
"jsc": {
"parser": {
"syntax": "typescript"
}
}
}

View File

@ -0,0 +1 @@
export const a = "a";

View File

@ -0,0 +1,7 @@
import { a as defaultA } from "./l.ts";
const o: { a?: string } = {};
const { a = defaultA } = o;
console.log(a);

View File

@ -0,0 +1 @@
export { a } from "./a.ts";

View 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);

View File

@ -0,0 +1,7 @@
{
"jsc": {
"parser": {
"syntax": "typescript"
}
}
}

View File

@ -0,0 +1 @@
export const defaultA = "a";

View File

@ -0,0 +1,7 @@
import { defaultA } from "./l.ts";
const o: { a?: string } = {};
const { a = defaultA } = o;
console.log(a);

View File

@ -0,0 +1 @@
export { defaultA } from "./a.ts";

View 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);

View File

@ -0,0 +1,7 @@
import * as circular1 from "./entry";
export function f2() {
console.log("f2");
}
circular1.f1();

View File

@ -0,0 +1,7 @@
import * as circular2 from "./a";
export function f1() {
console.log("f1");
}
circular2.f2();

View File

@ -0,0 +1,8 @@
export function f1() {
console.log("f1");
}
f2();
function f2() {
console.log("f2");
}
f1();

View File

@ -0,0 +1,7 @@
import * as circular2 from "./b";
export function f1() {
console.log("f1");
}
circular2.f2();

View File

@ -0,0 +1,7 @@
import * as circular1 from "./a";
export function f2() {
console.log("f2");
}
circular1.f1();

View File

@ -0,0 +1 @@
import './a';

View File

@ -0,0 +1,8 @@
function f1() {
console.log("f1");
}
f2();
function f2() {
console.log("f2");
}
f1();