diff options
author | 2021-09-23 22:01:34 -0700 | |
---|---|---|
committer | 2021-09-23 22:01:34 -0700 | |
commit | 4bb41b95a826892107b7ff3ff610d23d5afa96b6 (patch) | |
tree | 439f273d09ae8fa845eaec24c9e436c8fd244be3 /integration | |
parent | f78f4854a4e474a08023841f4714f0cd3774126b (diff) | |
download | bun-4bb41b95a826892107b7ff3ff610d23d5afa96b6.tar.gz bun-4bb41b95a826892107b7ff3ff610d23d5afa96b6.tar.zst bun-4bb41b95a826892107b7ff3ff610d23d5afa96b6.zip |
:camera:
Diffstat (limited to 'integration')
41 files changed, 1032 insertions, 387 deletions
diff --git a/integration/snapshots/array-args-with-default-values.debug.js b/integration/snapshots/array-args-with-default-values.debug.js new file mode 100644 index 000000000..d44564ff6 --- /dev/null +++ b/integration/snapshots/array-args-with-default-values.debug.js @@ -0,0 +1,25 @@ +var lines; +const data = () => lines.map(([a = null, b = null, c = null, d = null]) => ({ + a, + b, + c, + d +})); +export function test() { + let ran = false; + lines = [ + [undefined, undefined, undefined, undefined], + [undefined, undefined, undefined, undefined], + [undefined, undefined, undefined, undefined], + [undefined, undefined, undefined, undefined] + ]; + for (let foo of data()) { + console.assert(foo.a === null); + console.assert(foo.b === null); + console.assert(foo.c === null); + console.assert(foo.d === null); + ran = true; + } + console.assert(ran); + testDone(import.meta.url); +} diff --git a/integration/snapshots/array-args-with-default-values.hmr.debug.js b/integration/snapshots/array-args-with-default-values.hmr.debug.js new file mode 100644 index 000000000..58e8b47bf --- /dev/null +++ b/integration/snapshots/array-args-with-default-values.hmr.debug.js @@ -0,0 +1,47 @@ +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(3474597122, "array-args-with-default-values.js"), exports = hmr.exports; +(hmr._load = function() { + var lines; + const data = () => lines.map(([a = null, b = null, c = null, d = null]) => ({ + a, + b, + c, + d + })); + function test() { + let ran = false; + lines = [ + [undefined, undefined, undefined, undefined], + [undefined, undefined, undefined, undefined], + [undefined, undefined, undefined, undefined], + [undefined, undefined, undefined, undefined] + ]; + for (let foo of data()) { + console.assert(foo.a === null); + console.assert(foo.b === null); + console.assert(foo.c === null); + console.assert(foo.d === null); + ran = true; + } + console.assert(ran); + 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/array-args-with-default-values.hmr.js b/integration/snapshots/array-args-with-default-values.hmr.js new file mode 100644 index 000000000..aae356eed --- /dev/null +++ b/integration/snapshots/array-args-with-default-values.hmr.js @@ -0,0 +1,47 @@ +import { +__HMRModule as HMR +} from "http://localhost:8080/__runtime.js"; +import { +__HMRClient as Bun +} from "http://localhost:8080/__runtime.js"; +Bun.activate(false); + +var hmr = new HMR(3474597122, "array-args-with-default-values.js"), exports = hmr.exports; +(hmr._load = function() { + var lines; + const data = () => lines.map(([a = null, b = null, c = null, d = null]) => ({ + a, + b, + c, + d + })); + function test() { + let ran = false; + lines = [ + [undefined, undefined, undefined, undefined], + [undefined, undefined, undefined, undefined], + [undefined, undefined, undefined, undefined], + [undefined, undefined, undefined, undefined] + ]; + for (let foo of data()) { + console.assert(foo.a === null); + console.assert(foo.b === null); + console.assert(foo.c === null); + console.assert(foo.d === null); + ran = true; + } + console.assert(ran); + 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/array-args-with-default-values.js b/integration/snapshots/array-args-with-default-values.js new file mode 100644 index 000000000..d44564ff6 --- /dev/null +++ b/integration/snapshots/array-args-with-default-values.js @@ -0,0 +1,25 @@ +var lines; +const data = () => lines.map(([a = null, b = null, c = null, d = null]) => ({ + a, + b, + c, + d +})); +export function test() { + let ran = false; + lines = [ + [undefined, undefined, undefined, undefined], + [undefined, undefined, undefined, undefined], + [undefined, undefined, undefined, undefined], + [undefined, undefined, undefined, undefined] + ]; + for (let foo of data()) { + console.assert(foo.a === null); + console.assert(foo.b === null); + console.assert(foo.c === null); + console.assert(foo.d === null); + ran = true; + } + console.assert(ran); + testDone(import.meta.url); +} diff --git a/integration/snapshots/bundled-entry-point.hmr.js b/integration/snapshots/bundled-entry-point.hmr.js new file mode 100644 index 000000000..f3008327a --- /dev/null +++ b/integration/snapshots/bundled-entry-point.hmr.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(false); + +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 fd211daa2..04f92d63a 100644 --- a/integration/snapshots/bundled-entry-point.js +++ b/integration/snapshots/bundled-entry-point.js @@ -1,30 +1,9 @@ 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; -}; +var hello = null ?? "world"; -export { - $$hmr_test as test -}; +export function test() { + return testDone(import.meta.url); +} diff --git a/integration/snapshots/cjs-transform-shouldnt-have-static-imports-in-cjs-function.hmr.js b/integration/snapshots/cjs-transform-shouldnt-have-static-imports-in-cjs-function.hmr.js new file mode 100644 index 000000000..d8e3ccdd1 --- /dev/null +++ b/integration/snapshots/cjs-transform-shouldnt-have-static-imports-in-cjs-function.hmr.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/cjs-transform-shouldnt-have-static-imports-in-cjs-function.js b/integration/snapshots/cjs-transform-shouldnt-have-static-imports-in-cjs-function.js index d8e3ccdd1..d9f64c5b9 100644 --- a/integration/snapshots/cjs-transform-shouldnt-have-static-imports-in-cjs-function.js +++ b/integration/snapshots/cjs-transform-shouldnt-have-static-imports-in-cjs-function.js @@ -28,7 +28,7 @@ export default __cJS2eSM(function(module, exports) { return testDone(import.meta.url); }; Object.defineProperty(module.exports,"test",{get: () => test, enumerable: true, configurable: true}); - var foo, bar; + let 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/code-simplification-neql-define.debug.js b/integration/snapshots/code-simplification-neql-define.debug.js new file mode 100644 index 000000000..8c3ef20df --- /dev/null +++ b/integration/snapshots/code-simplification-neql-define.debug.js @@ -0,0 +1,28 @@ +var testFailed = false; +const invariant = () => { + testFailed = true; +}; +var $$m = (arg) => { + var module = {exports: {} }, exports = module.exports; + return arg(module, exports); +}; +var size = 100, ttl = 3600; +export var $f332019d = $$m({ + "relay-runtime/lib/network/RelayQueryResponseCache.js": (module, exports) => { + var RelayQueryResponseCache = function() { + var foo = function RelayQueryResponseCache(_ref) { + var size = _ref.size, ttl = _ref.ttl; + !(size > 0) && invariant(false, "RelayQueryResponseCache: Expected the max cache size to be > 0, got " + "`%s`.", size); + !(ttl > 0) && invariant(false, "RelayQueryResponseCache: Expected the max ttl to be > 0, got `%s`.", ttl); + }; + foo({size: 100, ttl: 3600 }); + }; + RelayQueryResponseCache(); + } +}["relay-runtime/lib/network/RelayQueryResponseCache.js"]); +export function test() { + var foo = () => result; + if (testFailed) + throw new Error("invariant should not be called"); + return testDone(import.meta.url); +} diff --git a/integration/snapshots/code-simplification-neql-define.hmr.debug.js b/integration/snapshots/code-simplification-neql-define.hmr.debug.js new file mode 100644 index 000000000..80aedf8bb --- /dev/null +++ b/integration/snapshots/code-simplification-neql-define.hmr.debug.js @@ -0,0 +1,53 @@ +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(726376257, "code-simplification-neql-define.js"), exports = hmr.exports; +(hmr._load = function() { + var testFailed = false; + const invariant = () => { + testFailed = true; + }; + var $$m = (arg) => { + var module = {exports: {} }, exports = module.exports; + return arg(module, exports); + }; + var size = 100, ttl = 3600; + var $f332019d = $$m({ + "relay-runtime/lib/network/RelayQueryResponseCache.js": (module, exports) => { + var RelayQueryResponseCache = function() { + var foo = function RelayQueryResponseCache(_ref) { + var size = _ref.size, ttl = _ref.ttl; + !(size > 0) && invariant(false, "RelayQueryResponseCache: Expected the max cache size to be > 0, got " + "`%s`.", size); + !(ttl > 0) && invariant(false, "RelayQueryResponseCache: Expected the max ttl to be > 0, got `%s`.", ttl); + }; + foo({size: 100, ttl: 3600 }); + }; + RelayQueryResponseCache(); + } + }["relay-runtime/lib/network/RelayQueryResponseCache.js"]); + function test() { + var foo = () => result; + if (testFailed) + throw new Error("invariant should not be called"); + return testDone(import.meta.url); + } + hmr.exportAll({ + $f332019d: () => $f332019d, + test: () => test + }); +})(); +var $$hmr_$f332019d = hmr.exports.$f332019d, $$hmr_test = hmr.exports.test; +hmr._update = function(exports) { + $$hmr_$f332019d = exports.$f332019d; + $$hmr_test = exports.test; +}; + +export { + $$hmr_$f332019d as $f332019d, + $$hmr_test as test +}; diff --git a/integration/snapshots/code-simplification-neql-define.hmr.js b/integration/snapshots/code-simplification-neql-define.hmr.js new file mode 100644 index 000000000..1e517c533 --- /dev/null +++ b/integration/snapshots/code-simplification-neql-define.hmr.js @@ -0,0 +1,53 @@ +import { +__HMRModule as HMR +} from "http://localhost:8080/__runtime.js"; +import { +__HMRClient as Bun +} from "http://localhost:8080/__runtime.js"; +Bun.activate(false); + +var hmr = new HMR(726376257, "code-simplification-neql-define.js"), exports = hmr.exports; +(hmr._load = function() { + var testFailed = false; + const invariant = () => { + testFailed = true; + }; + var $$m = (arg) => { + var module = {exports: {} }, exports = module.exports; + return arg(module, exports); + }; + var size = 100, ttl = 3600; + var $f332019d = $$m({ + "relay-runtime/lib/network/RelayQueryResponseCache.js": (module, exports) => { + var RelayQueryResponseCache = function() { + var foo = function RelayQueryResponseCache(_ref) { + var size = _ref.size, ttl = _ref.ttl; + !(size > 0) && invariant(false, "RelayQueryResponseCache: Expected the max cache size to be > 0, got " + "`%s`.", size); + !(ttl > 0) && invariant(false, "RelayQueryResponseCache: Expected the max ttl to be > 0, got `%s`.", ttl); + }; + foo({size: 100, ttl: 3600 }); + }; + RelayQueryResponseCache(); + } + }["relay-runtime/lib/network/RelayQueryResponseCache.js"]); + function test() { + var foo = () => result; + if (testFailed) + throw new Error("invariant should not be called"); + return testDone(import.meta.url); + } + hmr.exportAll({ + $f332019d: () => $f332019d, + test: () => test + }); +})(); +var $$hmr_$f332019d = hmr.exports.$f332019d, $$hmr_test = hmr.exports.test; +hmr._update = function(exports) { + $$hmr_$f332019d = exports.$f332019d; + $$hmr_test = exports.test; +}; + +export { + $$hmr_$f332019d as $f332019d, + $$hmr_test as test +}; diff --git a/integration/snapshots/code-simplification-neql-define.js b/integration/snapshots/code-simplification-neql-define.js new file mode 100644 index 000000000..8c3ef20df --- /dev/null +++ b/integration/snapshots/code-simplification-neql-define.js @@ -0,0 +1,28 @@ +var testFailed = false; +const invariant = () => { + testFailed = true; +}; +var $$m = (arg) => { + var module = {exports: {} }, exports = module.exports; + return arg(module, exports); +}; +var size = 100, ttl = 3600; +export var $f332019d = $$m({ + "relay-runtime/lib/network/RelayQueryResponseCache.js": (module, exports) => { + var RelayQueryResponseCache = function() { + var foo = function RelayQueryResponseCache(_ref) { + var size = _ref.size, ttl = _ref.ttl; + !(size > 0) && invariant(false, "RelayQueryResponseCache: Expected the max cache size to be > 0, got " + "`%s`.", size); + !(ttl > 0) && invariant(false, "RelayQueryResponseCache: Expected the max ttl to be > 0, got `%s`.", ttl); + }; + foo({size: 100, ttl: 3600 }); + }; + RelayQueryResponseCache(); + } +}["relay-runtime/lib/network/RelayQueryResponseCache.js"]); +export function test() { + var foo = () => result; + if (testFailed) + throw new Error("invariant should not be called"); + return testDone(import.meta.url); +} diff --git a/integration/snapshots/export.hmr.js b/integration/snapshots/export.hmr.js new file mode 100644 index 000000000..6088ffd77 --- /dev/null +++ b/integration/snapshots/export.hmr.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(false); + +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 b5d3e0ad1..534cb2a0c 100644 --- a/integration/snapshots/export.js +++ b/integration/snapshots/export.js @@ -1,74 +1,31 @@ -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 let yoyoyo = "yoyoyo"; + +export default function hey() { + return true; +} +export const foo = () => { +}; +export var bar = 100; +export let powerLevel = Symbol("9001"); + +export {what}; +export {what as when, what as whence}; export {} from "http://localhost:8080/_bacon.js"; +import * as where from "http://localhost:8080/_auth.js"; + +export {where}; + +export {bar as booop}; +export 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); +} diff --git a/integration/snapshots/forbid-in-is-correct.debug.js b/integration/snapshots/forbid-in-is-correct.debug.js new file mode 100644 index 000000000..2d36946ea --- /dev/null +++ b/integration/snapshots/forbid-in-is-correct.debug.js @@ -0,0 +1,8 @@ +var foo = () => { + var D = (i, r) => () => (r || i((r = {exports: {} }).exports, r), r.exports); + return D; +}; +export function test() { + foo(); + testDone(import.meta.url); +} diff --git a/integration/snapshots/forbid-in-is-correct.hmr.debug.js b/integration/snapshots/forbid-in-is-correct.hmr.debug.js new file mode 100644 index 000000000..7014ea1e8 --- /dev/null +++ b/integration/snapshots/forbid-in-is-correct.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(346837007, "forbid-in-is-correct.js"), exports = hmr.exports; +(hmr._load = function() { + var foo = () => { + var D = (i, r) => () => (r || i((r = {exports: {} }).exports, r), r.exports); + return D; + }; + function test() { + foo(); + 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/forbid-in-is-correct.hmr.js b/integration/snapshots/forbid-in-is-correct.hmr.js new file mode 100644 index 000000000..bd20b7b42 --- /dev/null +++ b/integration/snapshots/forbid-in-is-correct.hmr.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(false); + +var hmr = new HMR(346837007, "forbid-in-is-correct.js"), exports = hmr.exports; +(hmr._load = function() { + var foo = () => { + var D = (i, r) => () => (r || i((r = {exports: {} }).exports, r), r.exports); + return D; + }; + function test() { + foo(); + 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/forbid-in-is-correct.js b/integration/snapshots/forbid-in-is-correct.js new file mode 100644 index 000000000..2d36946ea --- /dev/null +++ b/integration/snapshots/forbid-in-is-correct.js @@ -0,0 +1,8 @@ +var foo = () => { + var D = (i, r) => () => (r || i((r = {exports: {} }).exports, r), r.exports); + return D; +}; +export function test() { + foo(); + testDone(import.meta.url); +} diff --git a/integration/snapshots/global-is-remapped-to-globalThis.hmr.js b/integration/snapshots/global-is-remapped-to-globalThis.hmr.js new file mode 100644 index 000000000..a5a3723a6 --- /dev/null +++ b/integration/snapshots/global-is-remapped-to-globalThis.hmr.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(false); + +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 dace8fa7a..9000d14b0 100644 --- a/integration/snapshots/global-is-remapped-to-globalThis.js +++ b/integration/snapshots/global-is-remapped-to-globalThis.js @@ -1,26 +1,4 @@ -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 -}; +export function test() { + console.assert(globalThis === globalThis); + return testDone(import.meta.url); +} diff --git a/integration/snapshots/lodash-regexp.hmr.js b/integration/snapshots/lodash-regexp.hmr.js new file mode 100644 index 000000000..cd9ca40f7 --- /dev/null +++ b/integration/snapshots/lodash-regexp.hmr.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(false); + +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 3030e47c6..6e0e6190a 100644 --- a/integration/snapshots/lodash-regexp.js +++ b/integration/snapshots/lodash-regexp.js @@ -1,41 +1,21 @@ 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); +export function test() { + const foo = [1, 2, 3, 4, 6]; -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); + 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"); } - hmr.exportAll({ - test: () => test - }); -})(); -var $$hmr_test = hmr.exports.test; -hmr._update = function(exports) { - $$hmr_test = exports.test; -}; + return testDone(import.meta.url); +} -export { - $$hmr_test as test -}; diff --git a/integration/snapshots/multiple-imports.hmr.js b/integration/snapshots/multiple-imports.hmr.js new file mode 100644 index 000000000..727907e62 --- /dev/null +++ b/integration/snapshots/multiple-imports.hmr.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(false); + +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 048988d09..7826c8765 100644 --- a/integration/snapshots/multiple-imports.js +++ b/integration/snapshots/multiple-imports.js @@ -1,12 +1,6 @@ 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); @@ -14,33 +8,18 @@ var jsx = require(JSX).jsxDEV, fileName = "multiple-imports.js", JSXFrag = requi 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; -}; +const bacon = React; -export { - $$hmr_test as test -}; +const bacon2 = jsx(JSXFrag, { + children: ["hello"] +}, undefined, true, { + fileName, + lineNumber: 92 +}, this); +export 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); +} diff --git a/integration/snapshots/package-json-exports/index.debug.js b/integration/snapshots/package-json-exports/index.debug.js index 0fdd7e692..1b260c7ea 100644 --- a/integration/snapshots/package-json-exports/index.debug.js +++ b/integration/snapshots/package-json-exports/index.debug.js @@ -7,7 +7,7 @@ import * as $d2a171d2 from "http://localhost:8080/package-json-exports/node_modu 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() { +export async function test() { console.assert(InexactRoot.target === "browser"); console.assert(InexactFile.target === "browser"); diff --git a/integration/snapshots/package-json-exports/index.hmr.debug.js b/integration/snapshots/package-json-exports/index.hmr.debug.js index 6d00451f2..59be5b753 100644 --- a/integration/snapshots/package-json-exports/index.hmr.debug.js +++ b/integration/snapshots/package-json-exports/index.hmr.debug.js @@ -17,7 +17,7 @@ Bun.activate(true); var hmr = new HMR(1953708113, "package-json-exports/index.js"), exports = hmr.exports; (hmr._load = function() { - function test() { + async function test() { console.assert(InexactRoot.target === "browser"); console.assert(InexactFile.target === "browser"); console.assert(ExactFile.target === "browser"); diff --git a/integration/snapshots/package-json-exports/index.hmr.js b/integration/snapshots/package-json-exports/index.hmr.js new file mode 100644 index 000000000..508dd63ee --- /dev/null +++ b/integration/snapshots/package-json-exports/index.hmr.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(false); + +var hmr = new HMR(1953708113, "package-json-exports/index.js"), exports = hmr.exports; +(hmr._load = function() { + async 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 index 6d00451f2..1b260c7ea 100644 --- a/integration/snapshots/package-json-exports/index.js +++ b/integration/snapshots/package-json-exports/index.js @@ -1,37 +1,17 @@ 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); +export async function test() { + console.assert(InexactRoot.target === "browser"); -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; -}; + console.assert(InexactFile.target === "browser"); + console.assert(ExactFile.target === "browser"); + return testDone(import.meta.url); +} -export { - $$hmr_test as test -}; diff --git a/integration/snapshots/string-escapes.hmr.js b/integration/snapshots/string-escapes.hmr.js new file mode 100644 index 000000000..9231cb6cf --- /dev/null +++ b/integration/snapshots/string-escapes.hmr.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(false); + +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 bc866d834..05d9c4ce2 100644 --- a/integration/snapshots/string-escapes.js +++ b/integration/snapshots/string-escapes.js @@ -1,57 +1,34 @@ -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; +var tab = "\t"; +var シ = "wow"; +var f = ""; +var obj = { + "\r\n": "\r\n", + "\n": "\n", + "\t": "\t", + "\u2028": "\u2028", + "\u2029": "\u2029", + "😊": "😊", + "😃": "😃", + "㋡": "㋡", + "☺": "☺", + シ: "シ", + f, + "☹": "☹", + "☻": "☻", + children: 123 }; - -export { - $$hmr_obj as obj, - $$hmr_test as test +const foo = () => { }; +const Bar = foo("a", { + children: 123 +}); +const carriage = obj["\r\n"]; +const newline = obj["\n"]; + +export {obj}; +export function test() { + console.assert(carriage === "\r\n"); + console.assert(newline === "\n"); + console.assert(tab === "\t"); + return testDone(import.meta.url); +} diff --git a/integration/snapshots/ts-fallback-rewrite-works.hmr.js b/integration/snapshots/ts-fallback-rewrite-works.hmr.js new file mode 100644 index 000000000..e728c5f14 --- /dev/null +++ b/integration/snapshots/ts-fallback-rewrite-works.hmr.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(false); + +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 c90ac6d25..a4e489f28 100644 --- a/integration/snapshots/ts-fallback-rewrite-works.js +++ b/integration/snapshots/ts-fallback-rewrite-works.js @@ -1,25 +1,3 @@ -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 -}; +export function test() { + return testDone(import.meta.url); +} diff --git a/integration/snapshots/tsx-fallback-rewrite-works.hmr.js b/integration/snapshots/tsx-fallback-rewrite-works.hmr.js new file mode 100644 index 000000000..3f2f754e2 --- /dev/null +++ b/integration/snapshots/tsx-fallback-rewrite-works.hmr.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(false); + +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 d3aa0919a..a4e489f28 100644 --- a/integration/snapshots/tsx-fallback-rewrite-works.js +++ b/integration/snapshots/tsx-fallback-rewrite-works.js @@ -1,25 +1,3 @@ -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 -}; +export function test() { + return testDone(import.meta.url); +} diff --git a/integration/snapshots/type-only-imports.hmr.ts b/integration/snapshots/type-only-imports.hmr.ts new file mode 100644 index 000000000..84740d0d9 --- /dev/null +++ b/integration/snapshots/type-only-imports.hmr.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(false); + +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 c647843ea..b4503474d 100644 --- a/integration/snapshots/type-only-imports.ts +++ b/integration/snapshots/type-only-imports.ts @@ -1,35 +1,7 @@ -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 -}; +export const baconator = true; +export const SilentSymbolCollisionsAreOkayInTypeScript = true; +export function test() { + console.assert(SilentSymbolCollisionsAreOkayInTypeScript); + console.assert(baconator); + return testDone(import.meta.url); +} diff --git a/integration/snapshots/unicode-identifiers.hmr.js b/integration/snapshots/unicode-identifiers.hmr.js new file mode 100644 index 000000000..5d465d559 --- /dev/null +++ b/integration/snapshots/unicode-identifiers.hmr.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(false); + +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 729365d1d..c495d69f6 100644 --- a/integration/snapshots/unicode-identifiers.js +++ b/integration/snapshots/unicode-identifiers.js @@ -1,30 +1,7 @@ -import { -__HMRModule as HMR -} from "http://localhost:8080/__runtime.js"; -import { -__HMRClient as Bun -} from "http://localhost:8080/__runtime.js"; -Bun.activate(true); +var ε = 1.0e-06, ε2 = ε * ε, π = Math.PI, τ = 2 * π, τε = τ - ε, halfπ = π / 2, d3_radians = π / 180, d3_degrees = 180 / π; -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 -}; +export {d3_radians}; +export function test() { + console.assert(ε === 1.0e-06); + return testDone(import.meta.url); +} diff --git a/integration/snippets/code-simplification-neql-define.js b/integration/snippets/code-simplification-neql-define.js new file mode 100644 index 000000000..ed5c5c395 --- /dev/null +++ b/integration/snippets/code-simplification-neql-define.js @@ -0,0 +1,56 @@ +var testFailed = false; +const invariant = () => { + testFailed = true; +}; +var $$m = (arg) => { + var module = { exports: {} }, + exports = module.exports; + return arg(module, exports); +}; +var size = 100, + ttl = 3600; + +export var $f332019d = $$m( + { + "relay-runtime/lib/network/RelayQueryResponseCache.js": ( + module, + exports + ) => { + var RelayQueryResponseCache = function () { + var foo = function RelayQueryResponseCache(_ref) { + var size = _ref.size, + ttl = _ref.ttl; + !(size > 0) + ? process.env.NODE_ENV !== "production" + ? invariant( + false, + "RelayQueryResponseCache: Expected the max cache size to be > 0, got " + + "`%s`.", + size + ) + : invariant(false) + : void 0; + !(ttl > 0) + ? process.env.NODE_ENV !== "production" + ? invariant( + false, + "RelayQueryResponseCache: Expected the max ttl to be > 0, got `%s`.", + ttl + ) + : invariant(false) + : void 0; + }; + foo({ size: 100, ttl: 3600 }); + }; + RelayQueryResponseCache(); + }, + }["relay-runtime/lib/network/RelayQueryResponseCache.js"] +); + +export function test() { + var foo = () => result; + // $f332019d; + + if (testFailed) throw new Error("invariant should not be called"); + return testDone(import.meta.url); +} diff --git a/integration/snippets/forbid-in-is-correct.js b/integration/snippets/forbid-in-is-correct.js new file mode 100644 index 000000000..cdd62bffb --- /dev/null +++ b/integration/snippets/forbid-in-is-correct.js @@ -0,0 +1,10 @@ +var foo = () => { + // prettier-ignore + var D=(i,r)=>()=>(r||i((r={exports:{}}).exports,r),r.exports); + return D; +}; + +export function test() { + foo(); + testDone(import.meta.url); +} diff --git a/integration/snippets/package-json-exports/index.js b/integration/snippets/package-json-exports/index.js index 7573e431c..899968a5d 100644 --- a/integration/snippets/package-json-exports/index.js +++ b/integration/snippets/package-json-exports/index.js @@ -7,6 +7,5 @@ export async function test() { console.assert(InexactFile.target === "browser"); console.assert(ExactFile.target === "browser"); - console.assert(failed); return testDone(import.meta.url); } |