diff options
author | 2021-09-22 01:02:32 -0700 | |
---|---|---|
committer | 2021-09-22 01:02:32 -0700 | |
commit | a48a02bade5079ab7c5ddd293ba8dc3b2f87ed26 (patch) | |
tree | 152843c5cac9910fe8e21610053a1a694325a553 | |
parent | 2326a1e1050d19a9b958893f07414f89e42dc82c (diff) | |
download | bun-a48a02bade5079ab7c5ddd293ba8dc3b2f87ed26.tar.gz bun-a48a02bade5079ab7c5ddd293ba8dc3b2f87ed26.tar.zst bun-a48a02bade5079ab7c5ddd293ba8dc3b2f87ed26.zip |
Switch to a single directory for storing snapshots and explicitly note whats a debug snapshot and a non-debug snapshot
55 files changed, 600 insertions, 20 deletions
@@ -115,21 +115,24 @@ test-install: test-all: test-install test-with-hmr test-no-hmr +copy-test-node-modules: + rm -rf integration/snippets/package-json-exports/node_modules + cp -r integration/snippets/package-json-exports/_node_modules_copy integration/snippets/package-json-exports/node_modules kill-bun: -killall -9 bun bun-debug -test-with-hmr: kill-bun +test-with-hmr: kill-bun copy-test-node-modules BUN_BIN=$(RELEASE_BUN) node integration/scripts/browser.js -test-no-hmr: kill-bun +test-no-hmr: kill-bun copy-test-node-modules -killall bun -9; DISABLE_HMR="DISABLE_HMR" BUN_BIN=$(RELEASE_BUN) node integration/scripts/browser.js -test-dev-with-hmr: +test-dev-with-hmr: copy-test-node-modules -killall bun-debug -9; BUN_BIN=$(DEBUG_BUN) node integration/scripts/browser.js -test-dev-no-hmr: +test-dev-no-hmr: copy-test-node-modules -killall bun-debug -9; DISABLE_HMR="DISABLE_HMR" BUN_BIN=$(DEBUG_BUN) node integration/scripts/browser.js diff --git a/integration/scripts/browser.js b/integration/scripts/browser.js index d062f93ca..8eb776c29 100644 --- a/integration/scripts/browser.js +++ b/integration/scripts/browser.js @@ -20,6 +20,7 @@ const bunProcess = child_process.spawn(bunExec, bunFlags, { shell: false, }); console.log("$", bunExec, bunFlags.join(" ")); +const isDebug = bunExec.endsWith("-debug"); bunProcess.stderr.pipe(process.stderr); bunProcess.stdout.pipe(process.stdout); @@ -32,12 +33,27 @@ process.on("beforeExit", () => { }); function writeSnapshot(name, code) { - const file = path.join( - __dirname, - "../snapshots" + (DISABLE_HMR ? "-no-hmr" : ""), - name + let file = path.join(__dirname, "../snapshots", name); + + if (!DISABLE_HMR) { + file = + file.substring(0, file.length - path.extname(file).length) + + ".hmr" + + path.extname(file); + } + + if (!fs.existsSync(path.dirname(file))) { + fs.mkdirSync(path.dirname(file), { recursive: true }); + } + + fs.writeFileSync( + isDebug + ? file.substring(0, file.length - path.extname(file).length) + + ".debug" + + path.extname(file) + : file, + code ); - fs.writeFileSync(file, code); } async function main() { @@ -97,6 +113,7 @@ async function main() { "/lodash-regexp.js", "/unicode-identifiers.js", "/string-escapes.js", + "/package-json-exports/index.js", ]; tests.reverse(); diff --git a/integration/snapshots-no-hmr/.prettierignore b/integration/snapshots-no-hmr/.prettierignore deleted file mode 100644 index 4c43fe68f..000000000 --- a/integration/snapshots-no-hmr/.prettierignore +++ /dev/null @@ -1 +0,0 @@ -*.js
\ No newline at end of file diff --git a/integration/snapshots-no-hmr/bundled-entry-point.js b/integration/snapshots/bundled-entry-point.debug.js index 04f92d63a..04f92d63a 100644 --- a/integration/snapshots-no-hmr/bundled-entry-point.js +++ b/integration/snapshots/bundled-entry-point.debug.js diff --git a/integration/snapshots/bundled-entry-point.hmr.debug.js b/integration/snapshots/bundled-entry-point.hmr.debug.js new file mode 100644 index 000000000..fd211daa2 --- /dev/null +++ b/integration/snapshots/bundled-entry-point.hmr.debug.js @@ -0,0 +1,30 @@ +import { +__require as require +} from "http://localhost:8080/__runtime.js"; +import { +__HMRModule as HMR +} from "http://localhost:8080/__runtime.js"; +import { +__HMRClient as Bun +} from "http://localhost:8080/__runtime.js"; +import * as $bbcd215f from "http://localhost:8080/node_modules/react/index.js"; +Bun.activate(true); + +var hmr = new HMR(3012834585, "bundled-entry-point.js"), exports = hmr.exports; +(hmr._load = function() { + var hello = null ?? "world"; + function test() { + return testDone(import.meta.url); + } + hmr.exportAll({ + test: () => test + }); +})(); +var $$hmr_test = hmr.exports.test; +hmr._update = function(exports) { + $$hmr_test = exports.test; +}; + +export { + $$hmr_test as test +}; diff --git a/integration/snapshots/bundled-entry-point.js b/integration/snapshots/bundled-entry-point.js index f3008327a..fd211daa2 100644 --- a/integration/snapshots/bundled-entry-point.js +++ b/integration/snapshots/bundled-entry-point.js @@ -8,7 +8,7 @@ import { __HMRClient as Bun } from "http://localhost:8080/__runtime.js"; import * as $bbcd215f from "http://localhost:8080/node_modules/react/index.js"; -Bun.activate(false); +Bun.activate(true); var hmr = new HMR(3012834585, "bundled-entry-point.js"), exports = hmr.exports; (hmr._load = function() { diff --git a/integration/snapshots-no-hmr/cjs-transform-shouldnt-have-static-imports-in-cjs-function.js b/integration/snapshots/cjs-transform-shouldnt-have-static-imports-in-cjs-function.debug.js index d9f64c5b9..d9f64c5b9 100644 --- a/integration/snapshots-no-hmr/cjs-transform-shouldnt-have-static-imports-in-cjs-function.js +++ b/integration/snapshots/cjs-transform-shouldnt-have-static-imports-in-cjs-function.debug.js diff --git a/integration/snapshots/cjs-transform-shouldnt-have-static-imports-in-cjs-function.hmr.debug.js b/integration/snapshots/cjs-transform-shouldnt-have-static-imports-in-cjs-function.hmr.debug.js new file mode 100644 index 000000000..d8e3ccdd1 --- /dev/null +++ b/integration/snapshots/cjs-transform-shouldnt-have-static-imports-in-cjs-function.hmr.debug.js @@ -0,0 +1,37 @@ +import { +__require as require +} from "http://localhost:8080/__runtime.js"; +import { +__cJS2eSM +} from "http://localhost:8080/__runtime.js"; +import * as _login_b977_0 from "http://localhost:8080/_login.js"; +import * as _login_b977_1 from "http://localhost:8080/_login.js"; +import _login from "http://localhost:8080/_login.js"; +import _auth from "http://localhost:8080/_auth.js"; +import * as _loginReally from "http://localhost:8080/_login.js"; +import * as _loginReally2 from "http://localhost:8080/_login.js"; +import * as _authReally from "http://localhost:8080/_auth.js"; + +export default __cJS2eSM(function(module, exports) { + ; + + ; + ; + ; + ; + module.exports.iAmCommonJs = true; + exports.YouAreCommonJS = true; + require(_login_b977_0); + require(_login_b977_1); + Object.defineProperty(module.exports,"login",{get: () => _login, enumerable: true, configurable: true}); + var test = function test() { + return testDone(import.meta.url); + }; + Object.defineProperty(module.exports,"test",{get: () => test, enumerable: true, configurable: true}); + var foo, bar; + Object.defineProperties(module.exports,{'foo': {get: () => foo, set: ($_newValue) => {foo = $_newValue;}, enumerable: true, configurable: true}, +'bar': {get: () => bar, set: ($_newValue) => {bar = $_newValue;}, enumerable: true, configurable: true}}); +}, "cjs-transform-shouldnt-have-static-imports-in-cjs-function.js"); + + + diff --git a/integration/snapshots-no-hmr/export.js b/integration/snapshots/export.debug.js index 534cb2a0c..534cb2a0c 100644 --- a/integration/snapshots-no-hmr/export.js +++ b/integration/snapshots/export.debug.js diff --git a/integration/snapshots/export.hmr.debug.js b/integration/snapshots/export.hmr.debug.js new file mode 100644 index 000000000..b5d3e0ad1 --- /dev/null +++ b/integration/snapshots/export.hmr.debug.js @@ -0,0 +1,74 @@ +import { +__HMRModule as HMR +} from "http://localhost:8080/__runtime.js"; +import { +__HMRClient as Bun +} from "http://localhost:8080/__runtime.js"; +import what from "http://localhost:8080/_auth.js"; +import * as where from "http://localhost:8080/_auth.js"; +Bun.activate(true); + +var hmr = new HMR(1879780259, "export.js"), exports = hmr.exports; +(hmr._load = function() { + var yoyoyo = "yoyoyo"; + function hey() { + return true; + } + var foo = () => { + }; + var bar = 100; + var powerLevel = Symbol("9001"); + function test() { + hey(); + foo(); + if (where.default !== "hi") + throw new Error(`_auth import is incorrect.`); + console.assert(powerLevel.description === "9001", "Symbol is not exported correctly"); + return testDone(import.meta.url); + } + hmr.exportAll({ + yoyoyo: () => yoyoyo, + default: () => hey, + foo: () => foo, + bar: () => bar, + powerLevel: () => powerLevel, + what: () => what, + when: () => what, + whence: () => what, + where: () => where, + booop: () => bar, + test: () => test + }); +})(); +var $$hmr_yoyoyo = hmr.exports.yoyoyo, $$hmr_default = hmr.exports.default, $$hmr_foo = hmr.exports.foo, $$hmr_bar = hmr.exports.bar, $$hmr_powerLevel = hmr.exports.powerLevel, $$hmr_what = hmr.exports.what, $$hmr_when = hmr.exports.when, $$hmr_whence = hmr.exports.whence, $$hmr_where = hmr.exports.where, $$hmr_booop = hmr.exports.booop, $$hmr_test = hmr.exports.test; +hmr._update = function(exports) { + $$hmr_yoyoyo = exports.yoyoyo; + $$hmr_default = exports.default; + $$hmr_foo = exports.foo; + $$hmr_bar = exports.bar; + $$hmr_powerLevel = exports.powerLevel; + $$hmr_what = exports.what; + $$hmr_when = exports.when; + $$hmr_whence = exports.whence; + $$hmr_where = exports.where; + $$hmr_booop = exports.booop; + $$hmr_test = exports.test; +}; + +export { + $$hmr_yoyoyo as yoyoyo, + $$hmr_default as default, + $$hmr_foo as foo, + $$hmr_bar as bar, + $$hmr_powerLevel as powerLevel, + $$hmr_what as what, + $$hmr_when as when, + $$hmr_whence as whence, + $$hmr_where as where, + $$hmr_booop as booop, + $$hmr_test as test +}; +export {default as auth} from "http://localhost:8080/_auth.js"; +export {default as login} from "http://localhost:8080/_login.js"; +export * from "http://localhost:8080/_bacon.js"; +export {} from "http://localhost:8080/_bacon.js"; diff --git a/integration/snapshots/export.js b/integration/snapshots/export.js index 6088ffd77..b5d3e0ad1 100644 --- a/integration/snapshots/export.js +++ b/integration/snapshots/export.js @@ -6,7 +6,7 @@ __HMRClient as Bun } from "http://localhost:8080/__runtime.js"; import what from "http://localhost:8080/_auth.js"; import * as where from "http://localhost:8080/_auth.js"; -Bun.activate(false); +Bun.activate(true); var hmr = new HMR(1879780259, "export.js"), exports = hmr.exports; (hmr._load = function() { diff --git a/integration/snapshots-no-hmr/global-is-remapped-to-globalThis.js b/integration/snapshots/global-is-remapped-to-globalThis.debug.js index 9000d14b0..9000d14b0 100644 --- a/integration/snapshots-no-hmr/global-is-remapped-to-globalThis.js +++ b/integration/snapshots/global-is-remapped-to-globalThis.debug.js diff --git a/integration/snapshots/global-is-remapped-to-globalThis.hmr.debug.js b/integration/snapshots/global-is-remapped-to-globalThis.hmr.debug.js new file mode 100644 index 000000000..dace8fa7a --- /dev/null +++ b/integration/snapshots/global-is-remapped-to-globalThis.hmr.debug.js @@ -0,0 +1,26 @@ +import { +__HMRModule as HMR +} from "http://localhost:8080/__runtime.js"; +import { +__HMRClient as Bun +} from "http://localhost:8080/__runtime.js"; +Bun.activate(true); + +var hmr = new HMR(713665787, "global-is-remapped-to-globalThis.js"), exports = hmr.exports; +(hmr._load = function() { + function test() { + console.assert(globalThis === globalThis); + return testDone(import.meta.url); + } + hmr.exportAll({ + test: () => test + }); +})(); +var $$hmr_test = hmr.exports.test; +hmr._update = function(exports) { + $$hmr_test = exports.test; +}; + +export { + $$hmr_test as test +}; diff --git a/integration/snapshots/global-is-remapped-to-globalThis.js b/integration/snapshots/global-is-remapped-to-globalThis.js index a5a3723a6..dace8fa7a 100644 --- a/integration/snapshots/global-is-remapped-to-globalThis.js +++ b/integration/snapshots/global-is-remapped-to-globalThis.js @@ -4,7 +4,7 @@ __HMRModule as HMR import { __HMRClient as Bun } from "http://localhost:8080/__runtime.js"; -Bun.activate(false); +Bun.activate(true); var hmr = new HMR(713665787, "global-is-remapped-to-globalThis.js"), exports = hmr.exports; (hmr._load = function() { diff --git a/integration/snapshots-no-hmr/lodash-regexp.js b/integration/snapshots/lodash-regexp.debug.js index 6e0e6190a..6e0e6190a 100644 --- a/integration/snapshots-no-hmr/lodash-regexp.js +++ b/integration/snapshots/lodash-regexp.debug.js diff --git a/integration/snapshots/lodash-regexp.hmr.debug.js b/integration/snapshots/lodash-regexp.hmr.debug.js new file mode 100644 index 000000000..3030e47c6 --- /dev/null +++ b/integration/snapshots/lodash-regexp.hmr.debug.js @@ -0,0 +1,41 @@ +import { +__require as require +} from "http://localhost:8080/__runtime.js"; +import { +__HMRModule as HMR +} from "http://localhost:8080/__runtime.js"; +import { +__HMRClient as Bun +} from "http://localhost:8080/__runtime.js"; +import * as $60f52dc2 from "http://localhost:8080/node_modules/lodash/lodash.js"; +var { shuffle} = require($60f52dc2); +Bun.activate(true); + +var hmr = new HMR(2158065009, "lodash-regexp.js"), exports = hmr.exports; +(hmr._load = function() { + function test() { + const foo = [1, 2, 3, 4, 6]; + const bar = shuffle(foo); + console.assert(bar !== foo); + console.assert(bar.length === foo.length); + bar.sort(); + foo.sort(); + for (let i = 0;i < bar.length; i++) { + console.assert(bar[i] === foo[i], "expected " + i + " to be " + foo[i]); + console.assert(typeof bar[i] === "number"); + console.assert(typeof foo[i] === "number"); + } + return testDone(import.meta.url); + } + hmr.exportAll({ + test: () => test + }); +})(); +var $$hmr_test = hmr.exports.test; +hmr._update = function(exports) { + $$hmr_test = exports.test; +}; + +export { + $$hmr_test as test +}; diff --git a/integration/snapshots/lodash-regexp.js b/integration/snapshots/lodash-regexp.js index cd9ca40f7..3030e47c6 100644 --- a/integration/snapshots/lodash-regexp.js +++ b/integration/snapshots/lodash-regexp.js @@ -9,7 +9,7 @@ __HMRClient as Bun } from "http://localhost:8080/__runtime.js"; import * as $60f52dc2 from "http://localhost:8080/node_modules/lodash/lodash.js"; var { shuffle} = require($60f52dc2); -Bun.activate(false); +Bun.activate(true); var hmr = new HMR(2158065009, "lodash-regexp.js"), exports = hmr.exports; (hmr._load = function() { diff --git a/integration/snapshots-no-hmr/multiple-imports.js b/integration/snapshots/multiple-imports.debug.js index 7826c8765..7826c8765 100644 --- a/integration/snapshots-no-hmr/multiple-imports.js +++ b/integration/snapshots/multiple-imports.debug.js diff --git a/integration/snapshots/multiple-imports.hmr.debug.js b/integration/snapshots/multiple-imports.hmr.debug.js new file mode 100644 index 000000000..048988d09 --- /dev/null +++ b/integration/snapshots/multiple-imports.hmr.debug.js @@ -0,0 +1,46 @@ +import { +__HMRClient as Bun +} from "http://localhost:8080/__runtime.js"; +import { +__require as require +} from "http://localhost:8080/__runtime.js"; +import { +__HMRModule as HMR +} from "http://localhost:8080/__runtime.js"; +import * as JSX from "http://localhost:8080/node_modules/react/jsx-dev-runtime.js"; +import * as $bbcd215f from "http://localhost:8080/node_modules/react/index.js"; +var JSXClassic = require($bbcd215f); +var jsx = require(JSX).jsxDEV, fileName = "multiple-imports.js", JSXFrag = require(JSX, JSXClassic).Fragment; + +var { default: React} = require($bbcd215f); +var { default: React2} = require($bbcd215f); +Bun.activate(true); + +var hmr = new HMR(2165509932, "multiple-imports.js"), exports = hmr.exports; +(hmr._load = function() { + const bacon = React; + const bacon2 = jsx(JSXFrag, { + children: ["hello"] + }, undefined, true, { + fileName, + lineNumber: 92 + }, this); + function test() { + console.assert(bacon === React); + console.assert(bacon === React2); + console.assert(typeof bacon2 !== "undefined"); + console.assert(React.isValidElement(bacon2)); + return testDone(import.meta.url); + } + hmr.exportAll({ + test: () => test + }); +})(); +var $$hmr_test = hmr.exports.test; +hmr._update = function(exports) { + $$hmr_test = exports.test; +}; + +export { + $$hmr_test as test +}; diff --git a/integration/snapshots/multiple-imports.js b/integration/snapshots/multiple-imports.js index 727907e62..048988d09 100644 --- a/integration/snapshots/multiple-imports.js +++ b/integration/snapshots/multiple-imports.js @@ -14,7 +14,7 @@ var jsx = require(JSX).jsxDEV, fileName = "multiple-imports.js", JSXFrag = requi var { default: React} = require($bbcd215f); var { default: React2} = require($bbcd215f); -Bun.activate(false); +Bun.activate(true); var hmr = new HMR(2165509932, "multiple-imports.js"), exports = hmr.exports; (hmr._load = function() { diff --git a/integration/snapshots/package-json-exports/index.debug.js b/integration/snapshots/package-json-exports/index.debug.js new file mode 100644 index 000000000..0fdd7e692 --- /dev/null +++ b/integration/snapshots/package-json-exports/index.debug.js @@ -0,0 +1,17 @@ +import { +__require as require +} from "http://localhost:8080/__runtime.js"; +import * as $4068f25b from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/index.js"; +var InexactRoot = require($4068f25b); +import * as $d2a171d2 from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/dir/file.js"; +var InexactFile = require($d2a171d2); +import * as $522c6d1f from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/foo.js"; +var ExactFile = require($522c6d1f); +export function test() { + console.assert(InexactRoot.target === "browser"); + + console.assert(InexactFile.target === "browser"); + console.assert(ExactFile.target === "browser"); + return testDone(import.meta.url); +} + diff --git a/integration/snapshots/package-json-exports/index.hmr.debug.js b/integration/snapshots/package-json-exports/index.hmr.debug.js new file mode 100644 index 000000000..6d00451f2 --- /dev/null +++ b/integration/snapshots/package-json-exports/index.hmr.debug.js @@ -0,0 +1,37 @@ +import { +__require as require +} from "http://localhost:8080/__runtime.js"; +import { +__HMRModule as HMR +} from "http://localhost:8080/__runtime.js"; +import { +__HMRClient as Bun +} from "http://localhost:8080/__runtime.js"; +import * as $4068f25b from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/index.js"; +var InexactRoot = require($4068f25b); +import * as $d2a171d2 from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/dir/file.js"; +var InexactFile = require($d2a171d2); +import * as $522c6d1f from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/foo.js"; +var ExactFile = require($522c6d1f); +Bun.activate(true); + +var hmr = new HMR(1953708113, "package-json-exports/index.js"), exports = hmr.exports; +(hmr._load = function() { + function test() { + console.assert(InexactRoot.target === "browser"); + console.assert(InexactFile.target === "browser"); + console.assert(ExactFile.target === "browser"); + return testDone(import.meta.url); + } + hmr.exportAll({ + test: () => test + }); +})(); +var $$hmr_test = hmr.exports.test; +hmr._update = function(exports) { + $$hmr_test = exports.test; +}; + +export { + $$hmr_test as test +}; diff --git a/integration/snapshots/package-json-exports/index.js b/integration/snapshots/package-json-exports/index.js new file mode 100644 index 000000000..6d00451f2 --- /dev/null +++ b/integration/snapshots/package-json-exports/index.js @@ -0,0 +1,37 @@ +import { +__require as require +} from "http://localhost:8080/__runtime.js"; +import { +__HMRModule as HMR +} from "http://localhost:8080/__runtime.js"; +import { +__HMRClient as Bun +} from "http://localhost:8080/__runtime.js"; +import * as $4068f25b from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/index.js"; +var InexactRoot = require($4068f25b); +import * as $d2a171d2 from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/dir/file.js"; +var InexactFile = require($d2a171d2); +import * as $522c6d1f from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/foo.js"; +var ExactFile = require($522c6d1f); +Bun.activate(true); + +var hmr = new HMR(1953708113, "package-json-exports/index.js"), exports = hmr.exports; +(hmr._load = function() { + function test() { + console.assert(InexactRoot.target === "browser"); + console.assert(InexactFile.target === "browser"); + console.assert(ExactFile.target === "browser"); + return testDone(import.meta.url); + } + hmr.exportAll({ + test: () => test + }); +})(); +var $$hmr_test = hmr.exports.test; +hmr._update = function(exports) { + $$hmr_test = exports.test; +}; + +export { + $$hmr_test as test +}; diff --git a/integration/snapshots-no-hmr/string-escapes.js b/integration/snapshots/string-escapes.debug.js index 05d9c4ce2..05d9c4ce2 100644 --- a/integration/snapshots-no-hmr/string-escapes.js +++ b/integration/snapshots/string-escapes.debug.js diff --git a/integration/snapshots/string-escapes.hmr.debug.js b/integration/snapshots/string-escapes.hmr.debug.js new file mode 100644 index 000000000..bc866d834 --- /dev/null +++ b/integration/snapshots/string-escapes.hmr.debug.js @@ -0,0 +1,57 @@ +import { +__HMRModule as HMR +} from "http://localhost:8080/__runtime.js"; +import { +__HMRClient as Bun +} from "http://localhost:8080/__runtime.js"; +Bun.activate(true); + +var hmr = new HMR(2482749838, "string-escapes.js"), exports = hmr.exports; +(hmr._load = function() { + var tab = "\t"; + var シ = "wow"; + var f = ""; + var obj = { + "\r\n": "\r\n", + "\n": "\n", + "\t": "\t", + "\u2028": "\u2028", + "\u2029": "\u2029", + "😊": "😊", + "😃": "😃", + "㋡": "㋡", + "☺": "☺", + シ: "シ", + f, + "☹": "☹", + "☻": "☻", + children: 123 + }; + const foo = () => { + }; + const Bar = foo("a", { + children: 123 + }); + const carriage = obj["\r\n"]; + const newline = obj["\n"]; + function test() { + console.assert(carriage === "\r\n"); + console.assert(newline === "\n"); + console.assert(tab === "\t"); + return testDone(import.meta.url); + } + hmr.exportAll({ + obj: () => obj, + test: () => test + }); +})(); +var $$hmr_obj = hmr.exports.obj, $$hmr_test = hmr.exports.test; +hmr._update = function(exports) { + $$hmr_obj = exports.obj; + $$hmr_test = exports.test; +}; + +export { + $$hmr_obj as obj, + $$hmr_test as test +}; diff --git a/integration/snapshots/string-escapes.js b/integration/snapshots/string-escapes.js index 9231cb6cf..bc866d834 100644 --- a/integration/snapshots/string-escapes.js +++ b/integration/snapshots/string-escapes.js @@ -4,7 +4,7 @@ __HMRModule as HMR import { __HMRClient as Bun } from "http://localhost:8080/__runtime.js"; -Bun.activate(false); +Bun.activate(true); var hmr = new HMR(2482749838, "string-escapes.js"), exports = hmr.exports; (hmr._load = function() { diff --git a/integration/snapshots-no-hmr/ts-fallback-rewrite-works.js b/integration/snapshots/ts-fallback-rewrite-works.debug.js index a4e489f28..a4e489f28 100644 --- a/integration/snapshots-no-hmr/ts-fallback-rewrite-works.js +++ b/integration/snapshots/ts-fallback-rewrite-works.debug.js diff --git a/integration/snapshots/ts-fallback-rewrite-works.hmr.debug.js b/integration/snapshots/ts-fallback-rewrite-works.hmr.debug.js new file mode 100644 index 000000000..c90ac6d25 --- /dev/null +++ b/integration/snapshots/ts-fallback-rewrite-works.hmr.debug.js @@ -0,0 +1,25 @@ +import { +__HMRModule as HMR +} from "http://localhost:8080/__runtime.js"; +import { +__HMRClient as Bun +} from "http://localhost:8080/__runtime.js"; +Bun.activate(true); + +var hmr = new HMR(421762902, "ts-fallback-rewrite-works.ts"), exports = hmr.exports; +(hmr._load = function() { + function test() { + return testDone(import.meta.url); + } + hmr.exportAll({ + test: () => test + }); +})(); +var $$hmr_test = hmr.exports.test; +hmr._update = function(exports) { + $$hmr_test = exports.test; +}; + +export { + $$hmr_test as test +}; diff --git a/integration/snapshots/ts-fallback-rewrite-works.js b/integration/snapshots/ts-fallback-rewrite-works.js index e728c5f14..c90ac6d25 100644 --- a/integration/snapshots/ts-fallback-rewrite-works.js +++ b/integration/snapshots/ts-fallback-rewrite-works.js @@ -4,7 +4,7 @@ __HMRModule as HMR import { __HMRClient as Bun } from "http://localhost:8080/__runtime.js"; -Bun.activate(false); +Bun.activate(true); var hmr = new HMR(421762902, "ts-fallback-rewrite-works.ts"), exports = hmr.exports; (hmr._load = function() { diff --git a/integration/snapshots-no-hmr/tsx-fallback-rewrite-works.js b/integration/snapshots/tsx-fallback-rewrite-works.debug.js index a4e489f28..a4e489f28 100644 --- a/integration/snapshots-no-hmr/tsx-fallback-rewrite-works.js +++ b/integration/snapshots/tsx-fallback-rewrite-works.debug.js diff --git a/integration/snapshots/tsx-fallback-rewrite-works.hmr.debug.js b/integration/snapshots/tsx-fallback-rewrite-works.hmr.debug.js new file mode 100644 index 000000000..d3aa0919a --- /dev/null +++ b/integration/snapshots/tsx-fallback-rewrite-works.hmr.debug.js @@ -0,0 +1,25 @@ +import { +__HMRModule as HMR +} from "http://localhost:8080/__runtime.js"; +import { +__HMRClient as Bun +} from "http://localhost:8080/__runtime.js"; +Bun.activate(true); + +var hmr = new HMR(2117426367, "tsx-fallback-rewrite-works.tsx"), exports = hmr.exports; +(hmr._load = function() { + function test() { + return testDone(import.meta.url); + } + hmr.exportAll({ + test: () => test + }); +})(); +var $$hmr_test = hmr.exports.test; +hmr._update = function(exports) { + $$hmr_test = exports.test; +}; + +export { + $$hmr_test as test +}; diff --git a/integration/snapshots/tsx-fallback-rewrite-works.js b/integration/snapshots/tsx-fallback-rewrite-works.js index 3f2f754e2..d3aa0919a 100644 --- a/integration/snapshots/tsx-fallback-rewrite-works.js +++ b/integration/snapshots/tsx-fallback-rewrite-works.js @@ -4,7 +4,7 @@ __HMRModule as HMR import { __HMRClient as Bun } from "http://localhost:8080/__runtime.js"; -Bun.activate(false); +Bun.activate(true); var hmr = new HMR(2117426367, "tsx-fallback-rewrite-works.tsx"), exports = hmr.exports; (hmr._load = function() { diff --git a/integration/snapshots-no-hmr/type-only-imports.ts b/integration/snapshots/type-only-imports.debug.ts index b4503474d..b4503474d 100644 --- a/integration/snapshots-no-hmr/type-only-imports.ts +++ b/integration/snapshots/type-only-imports.debug.ts diff --git a/integration/snapshots/type-only-imports.hmr.debug.ts b/integration/snapshots/type-only-imports.hmr.debug.ts new file mode 100644 index 000000000..c647843ea --- /dev/null +++ b/integration/snapshots/type-only-imports.hmr.debug.ts @@ -0,0 +1,35 @@ +import { +__HMRModule as HMR +} from "http://localhost:8080/__runtime.js"; +import { +__HMRClient as Bun +} from "http://localhost:8080/__runtime.js"; +Bun.activate(true); + +var hmr = new HMR(650094581, "type-only-imports.ts"), exports = hmr.exports; +(hmr._load = function() { + var baconator = true; + var SilentSymbolCollisionsAreOkayInTypeScript = true; + function test() { + console.assert(SilentSymbolCollisionsAreOkayInTypeScript); + console.assert(baconator); + return testDone(import.meta.url); + } + hmr.exportAll({ + baconator: () => baconator, + SilentSymbolCollisionsAreOkayInTypeScript: () => SilentSymbolCollisionsAreOkayInTypeScript, + test: () => test + }); +})(); +var $$hmr_baconator = hmr.exports.baconator, $$hmr_SilentSymbolCollisionsAreOkayInTypeScript = hmr.exports.SilentSymbolCollisionsAreOkayInTypeScript, $$hmr_test = hmr.exports.test; +hmr._update = function(exports) { + $$hmr_baconator = exports.baconator; + $$hmr_SilentSymbolCollisionsAreOkayInTypeScript = exports.SilentSymbolCollisionsAreOkayInTypeScript; + $$hmr_test = exports.test; +}; + +export { + $$hmr_baconator as baconator, + $$hmr_SilentSymbolCollisionsAreOkayInTypeScript as SilentSymbolCollisionsAreOkayInTypeScript, + $$hmr_test as test +}; diff --git a/integration/snapshots/type-only-imports.ts b/integration/snapshots/type-only-imports.ts index 84740d0d9..c647843ea 100644 --- a/integration/snapshots/type-only-imports.ts +++ b/integration/snapshots/type-only-imports.ts @@ -4,7 +4,7 @@ __HMRModule as HMR import { __HMRClient as Bun } from "http://localhost:8080/__runtime.js"; -Bun.activate(false); +Bun.activate(true); var hmr = new HMR(650094581, "type-only-imports.ts"), exports = hmr.exports; (hmr._load = function() { diff --git a/integration/snapshots-no-hmr/unicode-identifiers.js b/integration/snapshots/unicode-identifiers.debug.js index c495d69f6..c495d69f6 100644 --- a/integration/snapshots-no-hmr/unicode-identifiers.js +++ b/integration/snapshots/unicode-identifiers.debug.js diff --git a/integration/snapshots/unicode-identifiers.hmr.debug.js b/integration/snapshots/unicode-identifiers.hmr.debug.js new file mode 100644 index 000000000..729365d1d --- /dev/null +++ b/integration/snapshots/unicode-identifiers.hmr.debug.js @@ -0,0 +1,30 @@ +import { +__HMRModule as HMR +} from "http://localhost:8080/__runtime.js"; +import { +__HMRClient as Bun +} from "http://localhost:8080/__runtime.js"; +Bun.activate(true); + +var hmr = new HMR(1398361736, "unicode-identifiers.js"), exports = hmr.exports; +(hmr._load = function() { + var ε = 1.0e-06, ε2 = ε * ε, π = Math.PI, τ = 2 * π, τε = τ - ε, halfπ = π / 2, d3_radians = π / 180, d3_degrees = 180 / π; + function test() { + console.assert(ε === 1.0e-06); + return testDone(import.meta.url); + } + hmr.exportAll({ + d3_radians: () => d3_radians, + test: () => test + }); +})(); +var $$hmr_d3_radians = hmr.exports.d3_radians, $$hmr_test = hmr.exports.test; +hmr._update = function(exports) { + $$hmr_d3_radians = exports.d3_radians; + $$hmr_test = exports.test; +}; + +export { + $$hmr_d3_radians as d3_radians, + $$hmr_test as test +}; diff --git a/integration/snapshots/unicode-identifiers.js b/integration/snapshots/unicode-identifiers.js index 5d465d559..729365d1d 100644 --- a/integration/snapshots/unicode-identifiers.js +++ b/integration/snapshots/unicode-identifiers.js @@ -4,7 +4,7 @@ __HMRModule as HMR import { __HMRClient as Bun } from "http://localhost:8080/__runtime.js"; -Bun.activate(false); +Bun.activate(true); var hmr = new HMR(1398361736, "unicode-identifiers.js"), exports = hmr.exports; (hmr._load = function() { diff --git a/integration/snippets/package-json-exports/_node_modules_copy/exact/im-exact.js b/integration/snippets/package-json-exports/_node_modules_copy/exact/im-exact.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/integration/snippets/package-json-exports/_node_modules_copy/exact/im-exact.js diff --git a/integration/snippets/package-json-exports/_node_modules_copy/exact/package.json b/integration/snippets/package-json-exports/_node_modules_copy/exact/package.json new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/integration/snippets/package-json-exports/_node_modules_copy/exact/package.json diff --git a/integration/snippets/package-json-exports/_node_modules_copy/inexact/browser/dir/file.js b/integration/snippets/package-json-exports/_node_modules_copy/inexact/browser/dir/file.js new file mode 100644 index 000000000..26ab53d5b --- /dev/null +++ b/integration/snippets/package-json-exports/_node_modules_copy/inexact/browser/dir/file.js @@ -0,0 +1 @@ +export const target = "browser"; diff --git a/integration/snippets/package-json-exports/_node_modules_copy/inexact/browser/dir/foo.js b/integration/snippets/package-json-exports/_node_modules_copy/inexact/browser/dir/foo.js new file mode 100644 index 000000000..e54d9d4d6 --- /dev/null +++ b/integration/snippets/package-json-exports/_node_modules_copy/inexact/browser/dir/foo.js @@ -0,0 +1 @@ +export const target = 'browser';
\ No newline at end of file diff --git a/integration/snippets/package-json-exports/_node_modules_copy/inexact/browser/foo.js b/integration/snippets/package-json-exports/_node_modules_copy/inexact/browser/foo.js new file mode 100644 index 000000000..e54d9d4d6 --- /dev/null +++ b/integration/snippets/package-json-exports/_node_modules_copy/inexact/browser/foo.js @@ -0,0 +1 @@ +export const target = 'browser';
\ No newline at end of file diff --git a/integration/snippets/package-json-exports/_node_modules_copy/inexact/browser/index.js b/integration/snippets/package-json-exports/_node_modules_copy/inexact/browser/index.js new file mode 100644 index 000000000..e54d9d4d6 --- /dev/null +++ b/integration/snippets/package-json-exports/_node_modules_copy/inexact/browser/index.js @@ -0,0 +1 @@ +export const target = 'browser';
\ No newline at end of file diff --git a/integration/snippets/package-json-exports/_node_modules_copy/inexact/default/dir/file.js b/integration/snippets/package-json-exports/_node_modules_copy/inexact/default/dir/file.js new file mode 100644 index 000000000..826077c96 --- /dev/null +++ b/integration/snippets/package-json-exports/_node_modules_copy/inexact/default/dir/file.js @@ -0,0 +1 @@ +export const target = "default"; diff --git a/integration/snippets/package-json-exports/_node_modules_copy/inexact/default/dir/foo.js b/integration/snippets/package-json-exports/_node_modules_copy/inexact/default/dir/foo.js new file mode 100644 index 000000000..826077c96 --- /dev/null +++ b/integration/snippets/package-json-exports/_node_modules_copy/inexact/default/dir/foo.js @@ -0,0 +1 @@ +export const target = "default"; diff --git a/integration/snippets/package-json-exports/_node_modules_copy/inexact/default/foo.js b/integration/snippets/package-json-exports/_node_modules_copy/inexact/default/foo.js new file mode 100644 index 000000000..8fb5eac0c --- /dev/null +++ b/integration/snippets/package-json-exports/_node_modules_copy/inexact/default/foo.js @@ -0,0 +1 @@ +export const target = 'default'; diff --git a/integration/snippets/package-json-exports/_node_modules_copy/inexact/default/index.js b/integration/snippets/package-json-exports/_node_modules_copy/inexact/default/index.js new file mode 100644 index 000000000..826077c96 --- /dev/null +++ b/integration/snippets/package-json-exports/_node_modules_copy/inexact/default/index.js @@ -0,0 +1 @@ +export const target = "default"; diff --git a/integration/snippets/package-json-exports/_node_modules_copy/inexact/node/dir/file.js b/integration/snippets/package-json-exports/_node_modules_copy/inexact/node/dir/file.js new file mode 100644 index 000000000..301a88090 --- /dev/null +++ b/integration/snippets/package-json-exports/_node_modules_copy/inexact/node/dir/file.js @@ -0,0 +1 @@ +export const target = "node"; diff --git a/integration/snippets/package-json-exports/_node_modules_copy/inexact/node/dir/foo.js b/integration/snippets/package-json-exports/_node_modules_copy/inexact/node/dir/foo.js new file mode 100644 index 000000000..301a88090 --- /dev/null +++ b/integration/snippets/package-json-exports/_node_modules_copy/inexact/node/dir/foo.js @@ -0,0 +1 @@ +export const target = "node"; diff --git a/integration/snippets/package-json-exports/_node_modules_copy/inexact/node/foo.js b/integration/snippets/package-json-exports/_node_modules_copy/inexact/node/foo.js new file mode 100644 index 000000000..b9504cdf9 --- /dev/null +++ b/integration/snippets/package-json-exports/_node_modules_copy/inexact/node/foo.js @@ -0,0 +1 @@ +export const target = 'node';
\ No newline at end of file diff --git a/integration/snippets/package-json-exports/_node_modules_copy/inexact/node/index.js b/integration/snippets/package-json-exports/_node_modules_copy/inexact/node/index.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/integration/snippets/package-json-exports/_node_modules_copy/inexact/node/index.js diff --git a/integration/snippets/package-json-exports/_node_modules_copy/inexact/package.json b/integration/snippets/package-json-exports/_node_modules_copy/inexact/package.json new file mode 100644 index 000000000..1c9b5185d --- /dev/null +++ b/integration/snippets/package-json-exports/_node_modules_copy/inexact/package.json @@ -0,0 +1,20 @@ +{ + "name": "inexact", + "exports": { + ".": { + "node": "./node/index.js", + "browser": "./browser/index.js", + "default": "./default/index.js" + }, + "./foo": { + "node": "./node/foo.js", + "browser": "./browser/foo.js", + "default": "./default/foo.js" + }, + "./": { + "node": "./node/dir/", + "browser": "./browser/dir/", + "default": "./default/dir/" + } + } +} diff --git a/integration/snippets/package-json-exports/index.js b/integration/snippets/package-json-exports/index.js new file mode 100644 index 000000000..7603e0d59 --- /dev/null +++ b/integration/snippets/package-json-exports/index.js @@ -0,0 +1,10 @@ +import * as InexactRoot from "inexact"; +import * as InexactFile from "inexact/file"; +import * as ExactFile from "inexact/foo"; + +export function test() { + console.assert(InexactRoot.target === "browser"); + console.assert(InexactFile.target === "browser"); + console.assert(ExactFile.target === "browser"); + return testDone(import.meta.url); +} diff --git a/integration/snippets/package-json-exports/package.json b/integration/snippets/package-json-exports/package.json new file mode 100644 index 000000000..233a02208 --- /dev/null +++ b/integration/snippets/package-json-exports/package.json @@ -0,0 +1,3 @@ +{ + "name": "package-json-exports" +} |