Skip to content

Commit

Permalink
runtime: make some helper functions more compact
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed May 6, 2024
1 parent 316eee5 commit f426153
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 101 deletions.
20 changes: 10 additions & 10 deletions internal/bundler_tests/snapshots/snapshots_default.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4527,7 +4527,7 @@ copy
import {
__commonJS,
__require
} from "./chunk-WXLYCZIT.js";
} from "./chunk-MQN2VSL5.js";

// project/cjs.js
var require_cjs = __commonJS({
Expand Down Expand Up @@ -4558,23 +4558,23 @@ console.log(
e,
__require("extern-cjs"),
require_cjs(),
import("./dynamic-TGITTCVZ.js")
import("./dynamic-Q2DWDUFV.js")
);
var exported;
export {
exported
};

---------- /out/dynamic-TGITTCVZ.js ----------
import "./chunk-WXLYCZIT.js";
---------- /out/dynamic-Q2DWDUFV.js ----------
import "./chunk-MQN2VSL5.js";

// project/dynamic.js
var dynamic_default = 5;
export {
dynamic_default as default
};

---------- /out/chunk-WXLYCZIT.js ----------
---------- /out/chunk-MQN2VSL5.js ----------
export {
__require,
__commonJS
Expand Down Expand Up @@ -4731,7 +4731,7 @@ d {
"out/entry.js": {
"imports": [
{
"path": "out/chunk-WXLYCZIT.js",
"path": "out/chunk-MQN2VSL5.js",
"kind": "import-statement"
},
{
Expand All @@ -4753,7 +4753,7 @@ d {
"external": true
},
{
"path": "out/dynamic-TGITTCVZ.js",
"path": "out/dynamic-Q2DWDUFV.js",
"kind": "dynamic-import"
}
],
Expand All @@ -4780,10 +4780,10 @@ d {
},
"bytes": 642
},
"out/dynamic-TGITTCVZ.js": {
"out/dynamic-Q2DWDUFV.js": {
"imports": [
{
"path": "out/chunk-WXLYCZIT.js",
"path": "out/chunk-MQN2VSL5.js",
"kind": "import-statement"
}
],
Expand All @@ -4798,7 +4798,7 @@ d {
},
"bytes": 119
},
"out/chunk-WXLYCZIT.js": {
"out/chunk-MQN2VSL5.js": {
"imports": [],
"exports": [
"__commonJS",
Expand Down
64 changes: 32 additions & 32 deletions internal/bundler_tests/snapshots/snapshots_glob.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ TestGlobBasicSplitting
---------- /out/entry.js ----------
import {
require_a
} from "./chunk-Z3PINQB2.js";
} from "./chunk-KO426RN2.js";
import {
require_b
} from "./chunk-XAB6ATD2.js";
} from "./chunk-SGVK3D4Q.js";
import {
__glob
} from "./chunk-NI2FVOS3.js";
} from "./chunk-WCFE7E2E.js";

// require("./src/**/*") in entry.js
var globRequire_src = __glob({
Expand All @@ -75,8 +75,8 @@ var globRequire_src = __glob({

// import("./src/**/*") in entry.js
var globImport_src = __glob({
"./src/a.js": () => import("./a-G7HQS5H7.js"),
"./src/b.js": () => import("./b-DBW3WPXU.js")
"./src/a.js": () => import("./a-7QA47R6Z.js"),
"./src/b.js": () => import("./b-KY4MVCQS.js")
});

// entry.js
Expand All @@ -92,17 +92,17 @@ console.log({
}
});

---------- /out/a-G7HQS5H7.js ----------
---------- /out/a-7QA47R6Z.js ----------
import {
require_a
} from "./chunk-Z3PINQB2.js";
import "./chunk-NI2FVOS3.js";
} from "./chunk-KO426RN2.js";
import "./chunk-WCFE7E2E.js";
export default require_a();

---------- /out/chunk-Z3PINQB2.js ----------
---------- /out/chunk-KO426RN2.js ----------
import {
__commonJS
} from "./chunk-NI2FVOS3.js";
} from "./chunk-WCFE7E2E.js";

// src/a.js
var require_a = __commonJS({
Expand All @@ -115,17 +115,17 @@ export {
require_a
};

---------- /out/b-DBW3WPXU.js ----------
---------- /out/b-KY4MVCQS.js ----------
import {
require_b
} from "./chunk-XAB6ATD2.js";
import "./chunk-NI2FVOS3.js";
} from "./chunk-SGVK3D4Q.js";
import "./chunk-WCFE7E2E.js";
export default require_b();

---------- /out/chunk-XAB6ATD2.js ----------
---------- /out/chunk-SGVK3D4Q.js ----------
import {
__commonJS
} from "./chunk-NI2FVOS3.js";
} from "./chunk-WCFE7E2E.js";

// src/b.js
var require_b = __commonJS({
Expand All @@ -138,7 +138,7 @@ export {
require_b
};

---------- /out/chunk-NI2FVOS3.js ----------
---------- /out/chunk-WCFE7E2E.js ----------
export {
__glob,
__commonJS
Expand Down Expand Up @@ -321,13 +321,13 @@ TestTSGlobBasicSplitting
---------- /out/entry.js ----------
import {
require_a
} from "./chunk-NW3BCH2J.js";
} from "./chunk-YMCIDKCT.js";
import {
require_b
} from "./chunk-LX6LSYGO.js";
} from "./chunk-2BST4PYI.js";
import {
__glob
} from "./chunk-NI2FVOS3.js";
} from "./chunk-WCFE7E2E.js";

// require("./src/**/*") in entry.ts
var globRequire_src = __glob({
Expand All @@ -337,8 +337,8 @@ var globRequire_src = __glob({

// import("./src/**/*") in entry.ts
var globImport_src = __glob({
"./src/a.ts": () => import("./a-CIKLEGQA.js"),
"./src/b.ts": () => import("./b-UWTMLRMB.js")
"./src/a.ts": () => import("./a-YXM4MR7E.js"),
"./src/b.ts": () => import("./b-IPMBSSGN.js")
});

// entry.ts
Expand All @@ -354,17 +354,17 @@ console.log({
}
});

---------- /out/a-CIKLEGQA.js ----------
---------- /out/a-YXM4MR7E.js ----------
import {
require_a
} from "./chunk-NW3BCH2J.js";
import "./chunk-NI2FVOS3.js";
} from "./chunk-YMCIDKCT.js";
import "./chunk-WCFE7E2E.js";
export default require_a();

---------- /out/chunk-NW3BCH2J.js ----------
---------- /out/chunk-YMCIDKCT.js ----------
import {
__commonJS
} from "./chunk-NI2FVOS3.js";
} from "./chunk-WCFE7E2E.js";

// src/a.ts
var require_a = __commonJS({
Expand All @@ -377,17 +377,17 @@ export {
require_a
};

---------- /out/b-UWTMLRMB.js ----------
---------- /out/b-IPMBSSGN.js ----------
import {
require_b
} from "./chunk-LX6LSYGO.js";
import "./chunk-NI2FVOS3.js";
} from "./chunk-2BST4PYI.js";
import "./chunk-WCFE7E2E.js";
export default require_b();

---------- /out/chunk-LX6LSYGO.js ----------
---------- /out/chunk-2BST4PYI.js ----------
import {
__commonJS
} from "./chunk-NI2FVOS3.js";
} from "./chunk-WCFE7E2E.js";

// src/b.ts
var require_b = __commonJS({
Expand All @@ -400,7 +400,7 @@ export {
require_b
};

---------- /out/chunk-NI2FVOS3.js ----------
---------- /out/chunk-WCFE7E2E.js ----------
export {
__glob,
__commonJS
Expand Down
26 changes: 13 additions & 13 deletions internal/bundler_tests/snapshots/snapshots_splitting.txt
Original file line number Diff line number Diff line change
Expand Up @@ -259,19 +259,19 @@ TestSplittingDynamicAndNotDynamicCommonJSIntoES6
import {
__toESM,
require_foo
} from "./chunk-P5A5627R.js";
} from "./chunk-X3UWZZCR.js";

// entry.js
var import_foo = __toESM(require_foo());
import("./foo-N2LAC7TT.js").then(({ default: { bar: b } }) => console.log(import_foo.bar, b));
import("./foo-BJYZ44Z3.js").then(({ default: { bar: b } }) => console.log(import_foo.bar, b));

---------- /out/foo-N2LAC7TT.js ----------
---------- /out/foo-BJYZ44Z3.js ----------
import {
require_foo
} from "./chunk-P5A5627R.js";
} from "./chunk-X3UWZZCR.js";
export default require_foo();

---------- /out/chunk-P5A5627R.js ----------
---------- /out/chunk-X3UWZZCR.js ----------
// foo.js
var require_foo = __commonJS({
"foo.js"(exports) {
Expand Down Expand Up @@ -314,9 +314,9 @@ export {
TestSplittingDynamicCommonJSIntoES6
---------- /out/entry.js ----------
// entry.js
import("./foo-LH6ELO2A.js").then(({ default: { bar } }) => console.log(bar));
import("./foo-X6C7FV5C.js").then(({ default: { bar } }) => console.log(bar));

---------- /out/foo-LH6ELO2A.js ----------
---------- /out/foo-X6C7FV5C.js ----------
// foo.js
var require_foo = __commonJS({
"foo.js"(exports) {
Expand Down Expand Up @@ -371,7 +371,7 @@ TestSplittingHybridESMAndCJSIssue617
import {
foo,
init_a
} from "./chunk-P3Z6IJKQ.js";
} from "./chunk-PDZFCFBH.js";
init_a();
export {
foo
Expand All @@ -382,15 +382,15 @@ import {
__toCommonJS,
a_exports,
init_a
} from "./chunk-P3Z6IJKQ.js";
} from "./chunk-PDZFCFBH.js";

// b.js
var bar = (init_a(), __toCommonJS(a_exports));
export {
bar
};

---------- /out/chunk-P3Z6IJKQ.js ----------
---------- /out/chunk-PDZFCFBH.js ----------
// a.js
var a_exports = {};
__export(a_exports, {
Expand Down Expand Up @@ -541,7 +541,7 @@ TestSplittingSharedCommonJSIntoES6
---------- /out/a.js ----------
import {
require_shared
} from "./chunk-EJ4GJF3D.js";
} from "./chunk-JQJBVS2P.js";

// a.js
var { foo } = require_shared();
Expand All @@ -550,13 +550,13 @@ console.log(foo);
---------- /out/b.js ----------
import {
require_shared
} from "./chunk-EJ4GJF3D.js";
} from "./chunk-JQJBVS2P.js";

// b.js
var { foo } = require_shared();
console.log(foo);

---------- /out/chunk-EJ4GJF3D.js ----------
---------- /out/chunk-JQJBVS2P.js ----------
// shared.js
var require_shared = __commonJS({
"shared.js"(exports) {
Expand Down
Loading

0 comments on commit f426153

Please sign in to comment.