diff --git a/lib/HotModuleReplacementPlugin.js b/lib/HotModuleReplacementPlugin.js index 5c1f8483f..bed601f3a 100644 --- a/lib/HotModuleReplacementPlugin.js +++ b/lib/HotModuleReplacementPlugin.js @@ -12,7 +12,7 @@ const Compilation = require("./Compilation"); const HotUpdateChunk = require("./HotUpdateChunk"); const NormalModule = require("./NormalModule"); const RuntimeGlobals = require("./RuntimeGlobals"); -const HMRApiDependency = require("./dependencies/HMRApiDependency"); +const ConstDependency = require("./dependencies/ConstDependency"); const ImportMetaHotAcceptDependency = require("./dependencies/ImportMetaHotAcceptDependency"); const ImportMetaHotDeclineDependency = require("./dependencies/ImportMetaHotDeclineDependency"); const ModuleHotAcceptDependency = require("./dependencies/ModuleHotAcceptDependency"); @@ -83,17 +83,23 @@ class HotModuleReplacementPlugin { return callback(); } ); + const runtimeRequirements = [RuntimeGlobals.module]; - const createAcceptHandler = (parser, paramDependency) => { + const createAcceptHandler = (parser, ParamDependency) => { const { hotAcceptCallback, hotAcceptWithoutCallback } = HotModuleReplacementPlugin.getParserHooks(parser); return expr => { - const dep = new HMRApiDependency(expr.callee.range, "accept"); + const module = parser.state.module; + const dep = new ConstDependency( + `${module.moduleArgument}.hot.accept`, + expr.callee.range, + runtimeRequirements + ); dep.loc = expr.loc; - parser.state.module.addDependency(dep); + module.addPresentationalDependency(dep); if (expr.arguments.length >= 1) { const arg = parser.evaluateExpression(expr.arguments[0]); let params = []; @@ -106,11 +112,11 @@ class HotModuleReplacementPlugin { if (params.length > 0) { params.forEach((param, idx) => { const request = param.string; - const dep = new paramDependency(request, param.range); + const dep = new ParamDependency(request, param.range); dep.optional = true; dep.loc = Object.create(expr.loc); dep.loc.index = idx; - parser.state.module.addDependency(dep); + module.addDependency(dep); requests.push(request); }); if (expr.arguments.length > 1) { @@ -128,10 +134,15 @@ class HotModuleReplacementPlugin { }; }; - const createDeclineHandler = (parser, paramDependency) => expr => { - const dep = new HMRApiDependency(expr.callee.range, "decline"); + const createDeclineHandler = (parser, ParamDependency) => expr => { + const module = parser.state.module; + const dep = new ConstDependency( + `${module.moduleArgument}.hot.decline`, + expr.callee.range, + runtimeRequirements + ); dep.loc = expr.loc; - parser.state.module.addDependency(dep); + module.addPresentationalDependency(dep); if (expr.arguments.length === 1) { const arg = parser.evaluateExpression(expr.arguments[0]); let params = []; @@ -141,20 +152,25 @@ class HotModuleReplacementPlugin { params = arg.items.filter(param => param.isString()); } params.forEach((param, idx) => { - const dep = new paramDependency(param.string, param.range); + const dep = new ParamDependency(param.string, param.range); dep.optional = true; dep.loc = Object.create(expr.loc); dep.loc.index = idx; - parser.state.module.addDependency(dep); + module.addDependency(dep); }); } return true; }; const createHMRExpressionHandler = parser => expr => { - const dep = new HMRApiDependency(expr.range); + const module = parser.state.module; + const dep = new ConstDependency( + `${module.moduleArgument}.hot`, + expr.range, + runtimeRequirements + ); dep.loc = expr.loc; - parser.state.module.addDependency(dep); + module.addPresentationalDependency(dep); return true; }; @@ -192,29 +208,29 @@ class HotModuleReplacementPlugin { const applyImportMetaHot = parser => { parser.hooks.evaluateIdentifier - .for("import.meta.hot") + .for("import.meta.webpackHot") .tap("HotModuleReplacementPlugin", expr => { return evaluateToIdentifier( - "import.meta.hot", + "import.meta.webpackHot", "import.meta", - () => ["hot"], + () => ["webpackHot"], true )(expr); }); parser.hooks.call - .for("import.meta.hot.accept") + .for("import.meta.webpackHot.accept") .tap( "HotModuleReplacementPlugin", createAcceptHandler(parser, ImportMetaHotAcceptDependency) ); parser.hooks.call - .for("import.meta.hot.decline") + .for("import.meta.webpackHot.decline") .tap( "HotModuleReplacementPlugin", createDeclineHandler(parser, ImportMetaHotDeclineDependency) ); parser.hooks.expression - .for("import.meta.hot") + .for("import.meta.webpackHot") .tap("HotModuleReplacementPlugin", createHMRExpressionHandler(parser)); }; @@ -258,7 +274,7 @@ class HotModuleReplacementPlugin { ); //#endregion - //#region import.meta.hot.* API + //#region import.meta.webpackHot.* API compilation.dependencyFactories.set( ImportMetaHotAcceptDependency, normalModuleFactory @@ -277,11 +293,6 @@ class HotModuleReplacementPlugin { ); //#endregion - compilation.dependencyTemplates.set( - HMRApiDependency, - new HMRApiDependency.Template() - ); - compilation.hooks.record.tap( "HotModuleReplacementPlugin", (compilation, records) => { diff --git a/lib/dependencies/HMRApiDependency.js b/lib/dependencies/HMRApiDependency.js deleted file mode 100644 index b47b5d01f..000000000 --- a/lib/dependencies/HMRApiDependency.js +++ /dev/null @@ -1,67 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const RuntimeGlobals = require("../RuntimeGlobals"); -const makeSerializable = require("../util/makeSerializable"); -const NullDependency = require("./NullDependency"); - -/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ -/** @typedef {import("../Dependency")} Dependency */ -/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ - -class HMRApiDependency extends NullDependency { - constructor(range, apiMethod) { - super(); - - this.range = range; - this.apiMethod = apiMethod; - } - - get type() { - return "module.hot and import.meta.hot"; - } - - serialize(context) { - const { write } = context; - - write(this.range); - write(this.apiMethod); - - super.serialize(context); - } - - deserialize(context) { - const { read } = context; - - this.range = read(); - this.apiMethod = read(); - - super.deserialize(context); - } -} - -makeSerializable(HMRApiDependency, "webpack/lib/dependencies/HMRApiDependency"); - -HMRApiDependency.Template = class HMRApiDependencyTemplate extends NullDependency.Template { - /** - * @param {Dependency} dependency the dependency for which the template should be applied - * @param {ReplaceSource} source the current replace source which can be modified - * @param {DependencyTemplateContext} templateContext the context object - * @returns {void} - */ - apply(dependency, source, { module, runtimeRequirements }) { - const dep = /** @type {HMRApiDependency} */ (dependency); - runtimeRequirements.add(RuntimeGlobals.module); - source.replace( - dep.range[0], - dep.range[1] - 1, - `${module.moduleArgument}.hot${dep.apiMethod ? `.${dep.apiMethod}` : ""}` - ); - } -}; - -module.exports = HMRApiDependency; diff --git a/lib/dependencies/ImportMetaHotAcceptDependency.js b/lib/dependencies/ImportMetaHotAcceptDependency.js index 144cdb6a3..66329d7fc 100644 --- a/lib/dependencies/ImportMetaHotAcceptDependency.js +++ b/lib/dependencies/ImportMetaHotAcceptDependency.js @@ -17,7 +17,7 @@ class ImportMetaHotAcceptDependency extends ModuleDependency { } get type() { - return "import.meta.hot.accept"; + return "import.meta.webpackHot.accept"; } get category() { diff --git a/lib/dependencies/ImportMetaHotDeclineDependency.js b/lib/dependencies/ImportMetaHotDeclineDependency.js index 17f7b3ec3..b9d1a5a57 100644 --- a/lib/dependencies/ImportMetaHotDeclineDependency.js +++ b/lib/dependencies/ImportMetaHotDeclineDependency.js @@ -18,7 +18,7 @@ class ImportMetaHotDeclineDependency extends ModuleDependency { } get type() { - return "import.meta.hot.decline"; + return "import.meta.webpackHot.decline"; } get category() { diff --git a/lib/util/internalSerializables.js b/lib/util/internalSerializables.js index cfb352d9b..473d6b7fa 100644 --- a/lib/util/internalSerializables.js +++ b/lib/util/internalSerializables.js @@ -113,8 +113,6 @@ module.exports = { require("../dependencies/ImportMetaHotAcceptDependency"), "dependencies/ImportMetaHotDeclineDependency": () => require("../dependencies/ImportMetaHotDeclineDependency"), - "dependencies/HMRApiDependency": () => - require("../dependencies/HMRApiDependency"), "dependencies/ProvidedDependency": () => require("../dependencies/ProvidedDependency"), "dependencies/PureExpressionDependency": () => diff --git a/test/hotCases/chunks/accept-system-import-webpackhot/chunk.js b/test/hotCases/chunks/accept-system-import-webpackhot/chunk.js new file mode 100644 index 000000000..628afead3 --- /dev/null +++ b/test/hotCases/chunks/accept-system-import-webpackhot/chunk.js @@ -0,0 +1 @@ +export { value } from "./file"; diff --git a/test/hotCases/chunks/accept-system-import-webpackhot/chunk2.js b/test/hotCases/chunks/accept-system-import-webpackhot/chunk2.js new file mode 100644 index 000000000..628afead3 --- /dev/null +++ b/test/hotCases/chunks/accept-system-import-webpackhot/chunk2.js @@ -0,0 +1 @@ +export { value } from "./file"; diff --git a/test/hotCases/errors/esm-dependency-import/node_modules/dep1/file.js b/test/hotCases/chunks/accept-system-import-webpackhot/file.js similarity index 100% rename from test/hotCases/errors/esm-dependency-import/node_modules/dep1/file.js rename to test/hotCases/chunks/accept-system-import-webpackhot/file.js diff --git a/test/hotCases/chunks/accept-system-import-webpackhot/index.js b/test/hotCases/chunks/accept-system-import-webpackhot/index.js new file mode 100644 index 000000000..87a73c395 --- /dev/null +++ b/test/hotCases/chunks/accept-system-import-webpackhot/index.js @@ -0,0 +1,18 @@ +it("should import a changed chunk", (done) => { + import("./chunk").then((chunk) => { + expect(chunk.value).toBe(1); + import("./chunk2").then((chunk2) => { + expect(chunk2.value).toBe(1); + NEXT(require("../../update")(done)); + import.meta.webpackHot.accept(["./chunk", "./chunk2"], () => { + import("./chunk").then((chunk) => { + expect(chunk.value).toBe(2); + import("./chunk2").then((chunk2) => { + expect(chunk2.value).toBe(2); + done(); + }).catch(done); + }).catch(done); + }); + }).catch(done); + }).catch(done); +}); diff --git a/test/hotCases/chunks/accept-system-import/file.js b/test/hotCases/chunks/accept-system-import/file.js index f1414783d..5b2c52ba4 100644 --- a/test/hotCases/chunks/accept-system-import/file.js +++ b/test/hotCases/chunks/accept-system-import/file.js @@ -1,5 +1,3 @@ export var value = 1; --- export var value = 2; ---- -export var value = 3; diff --git a/test/hotCases/chunks/accept-system-import/index.js b/test/hotCases/chunks/accept-system-import/index.js index a4be0c2cf..33bdc93b4 100644 --- a/test/hotCases/chunks/accept-system-import/index.js +++ b/test/hotCases/chunks/accept-system-import/index.js @@ -1,4 +1,4 @@ -it("should import a changed chunk using module.hot.accept API", (done) => { +it("should import a changed chunk", (done) => { import("./chunk").then((chunk) => { expect(chunk.value).toBe(1); import("./chunk2").then((chunk2) => { @@ -16,22 +16,3 @@ it("should import a changed chunk using module.hot.accept API", (done) => { }).catch(done); }).catch(done); }); - -it("should import a changed chunk using import.meta.hot.accept API", (done) => { - import("./chunk").then((chunk) => { - expect(chunk.value).toBe(2); - import("./chunk2").then((chunk2) => { - expect(chunk2.value).toBe(2); - NEXT(require("../../update")(done)); - import.meta.hot.accept(["./chunk", "./chunk2"], () => { - import("./chunk").then((chunk) => { - expect(chunk.value).toBe(3); - import("./chunk2").then((chunk2) => { - expect(chunk2.value).toBe(3); - done(); - }).catch(done); - }).catch(done); - }); - }).catch(done); - }).catch(done); -}); diff --git a/test/hotCases/chunks/split-chunks-webpackhot/index.js b/test/hotCases/chunks/split-chunks-webpackhot/index.js new file mode 100644 index 000000000..02623b704 --- /dev/null +++ b/test/hotCases/chunks/split-chunks-webpackhot/index.js @@ -0,0 +1,11 @@ +import vendor from "vendor"; +import.meta.webpackHot.accept("vendor"); +it("should hot update a splitted initial chunk", function (done) { + expect(vendor).toBe("1"); + NEXT( + require("../../update")(done, true, () => { + expect(vendor).toBe("2"); + done(); + }) + ); +}); diff --git a/test/hotCases/chunks/split-chunks-webpackhot/node_modules/vendor.js b/test/hotCases/chunks/split-chunks-webpackhot/node_modules/vendor.js new file mode 100644 index 000000000..866bdccb5 --- /dev/null +++ b/test/hotCases/chunks/split-chunks-webpackhot/node_modules/vendor.js @@ -0,0 +1,3 @@ +module.exports = "1"; +--- +module.exports = "2"; diff --git a/test/hotCases/chunks/split-chunks-webpackhot/webpack.config.js b/test/hotCases/chunks/split-chunks-webpackhot/webpack.config.js new file mode 100644 index 000000000..f6b853139 --- /dev/null +++ b/test/hotCases/chunks/split-chunks-webpackhot/webpack.config.js @@ -0,0 +1,12 @@ +module.exports = { + output: { + filename: "[name].js" + }, + optimization: { + chunkIds: "total-size", + splitChunks: { + chunks: "all", + minSize: 0 + } + } +}; diff --git a/test/hotCases/chunks/split-chunks/index.js b/test/hotCases/chunks/split-chunks/index.js index 117f77897..4965d6890 100644 --- a/test/hotCases/chunks/split-chunks/index.js +++ b/test/hotCases/chunks/split-chunks/index.js @@ -1,6 +1,6 @@ import vendor from "vendor"; -import.meta.hot.accept("vendor"); -it("should hot update a splitted initial chunk using import.meta.hot.* API", function (done) { +module.hot.accept("vendor"); +it("should hot update a splitted initial chunk", function (done) { expect(vendor).toBe("1"); NEXT( require("../../update")(done, true, () => { @@ -9,14 +9,3 @@ it("should hot update a splitted initial chunk using import.meta.hot.* API", fun }) ); }); - -it("should hot update a splitted initial chunk using module.hot.* API", function (done) { - expect(vendor).toBe("2"); - module.hot.accept("vendor"); - NEXT( - require("../../update")(done, true, () => { - expect(vendor).toBe("3"); - done(); - }) - ); -}); diff --git a/test/hotCases/chunks/split-chunks/node_modules/vendor.js b/test/hotCases/chunks/split-chunks/node_modules/vendor.js index 880366e11..866bdccb5 100644 --- a/test/hotCases/chunks/split-chunks/node_modules/vendor.js +++ b/test/hotCases/chunks/split-chunks/node_modules/vendor.js @@ -1,5 +1,3 @@ module.exports = "1"; --- module.exports = "2"; ---- -module.exports = "3"; diff --git a/test/hotCases/code-generation/this-in-accept-webpackhot/index.js b/test/hotCases/code-generation/this-in-accept-webpackhot/index.js new file mode 100644 index 000000000..55be5b27a --- /dev/null +++ b/test/hotCases/code-generation/this-in-accept-webpackhot/index.js @@ -0,0 +1,15 @@ +import x from "./module"; + +it("should have correct this context", (done) => { + expect(x).toEqual("ok1"); + + (function() { + import.meta.webpackHot.accept("./module", () => { + expect(x).toEqual("ok2"); + expect(this).toEqual({ ok: true }); + done(); + }); + }).call({ ok: true }); + + NEXT(require("../../update")(done)); +}); diff --git a/test/hotCases/code-generation/this-in-accept-webpackhot/module.js b/test/hotCases/code-generation/this-in-accept-webpackhot/module.js new file mode 100644 index 000000000..93b538def --- /dev/null +++ b/test/hotCases/code-generation/this-in-accept-webpackhot/module.js @@ -0,0 +1,3 @@ +export default "ok1"; +--- +export default "ok2"; diff --git a/test/hotCases/code-generation/this-in-accept/index.js b/test/hotCases/code-generation/this-in-accept/index.js index 0f53b42c3..955eaa064 100644 --- a/test/hotCases/code-generation/this-in-accept/index.js +++ b/test/hotCases/code-generation/this-in-accept/index.js @@ -1,6 +1,6 @@ import x from "./module"; -it("should have correct this context in module.hot.accept handler", (done) => { +it("should have correct this context in accept handler", (done) => { expect(x).toEqual("ok1"); (function() { @@ -13,17 +13,3 @@ it("should have correct this context in module.hot.accept handler", (done) => { NEXT(require("../../update")(done)); }); - -it("should have correct this context in import.meta.hot.accept handler", (done) => { - expect(x).toEqual("ok2"); - - (function() { - import.meta.hot.accept("./module", () => { - expect(x).toEqual("ok3"); - expect(this).toEqual({ ok: true }); - done(); - }); - }).call({ ok: true }); - - NEXT(require("../../update")(done)); -}); diff --git a/test/hotCases/code-generation/this-in-accept/module.js b/test/hotCases/code-generation/this-in-accept/module.js index 97776e45d..93b538def 100644 --- a/test/hotCases/code-generation/this-in-accept/module.js +++ b/test/hotCases/code-generation/this-in-accept/module.js @@ -1,5 +1,3 @@ export default "ok1"; --- export default "ok2"; ---- -export default "ok3"; diff --git a/test/hotCases/errors/decline-webpackhot/a.js b/test/hotCases/errors/decline-webpackhot/a.js new file mode 100644 index 000000000..329853db7 --- /dev/null +++ b/test/hotCases/errors/decline-webpackhot/a.js @@ -0,0 +1,8 @@ +import b from "./b"; + +export default b; + +if(import.meta.webpackHot) { + import.meta.webpackHot.decline("./b"); + import.meta.webpackHot.accept(); +} diff --git a/test/hotCases/errors/decline-webpackhot/b.js b/test/hotCases/errors/decline-webpackhot/b.js new file mode 100644 index 000000000..cb7873fad --- /dev/null +++ b/test/hotCases/errors/decline-webpackhot/b.js @@ -0,0 +1 @@ +export { default } from "./c" diff --git a/test/hotCases/errors/decline-webpackhot/c.js b/test/hotCases/errors/decline-webpackhot/c.js new file mode 100644 index 000000000..4fd270707 --- /dev/null +++ b/test/hotCases/errors/decline-webpackhot/c.js @@ -0,0 +1,3 @@ +export default 1; +--- +export default 2; diff --git a/test/hotCases/errors/decline-webpackhot/index.js b/test/hotCases/errors/decline-webpackhot/index.js new file mode 100644 index 000000000..01e094ed4 --- /dev/null +++ b/test/hotCases/errors/decline-webpackhot/index.js @@ -0,0 +1,14 @@ +import a from "./a"; + +it("should abort when module is declined by parent", (done) => { + expect(a).toBe(1); + NEXT(require("../../update")((err) => { + try { + expect(err.message).toMatch(/Aborted because of declined dependency: \.\/b\.js in \.\/a\.js/); + expect(err.message).toMatch(/Update propagation: \.\/c\.js -> \.\/b\.js -> \.\/a\.js/); + done(); + } catch(e) { + done(e); + } + })); +}); diff --git a/test/hotCases/errors/decline/a.js b/test/hotCases/errors/decline/a.js index 09b0e6473..47850d32d 100644 --- a/test/hotCases/errors/decline/a.js +++ b/test/hotCases/errors/decline/a.js @@ -2,7 +2,7 @@ import b from "./b"; export default b; -if(import.meta.hot) { - import.meta.hot.decline("./b"); - import.meta.hot.accept(); +if(module.hot) { + module.hot.decline("./b"); + module.hot.accept(); } diff --git a/test/hotCases/esm-dependency-import/import-meta-webpack-hot/index.js b/test/hotCases/esm-dependency-import/import-meta-webpack-hot/index.js new file mode 100644 index 000000000..7d0f634e0 --- /dev/null +++ b/test/hotCases/esm-dependency-import/import-meta-webpack-hot/index.js @@ -0,0 +1,7 @@ +import {val} from "./module"; + +it("should accept changes", (done) => { + expect(val).toBe(1); + NEXT(require("../../update")(done)); + done(); +}); diff --git a/test/hotCases/esm-dependency-import/import-meta-webpack-hot/module.js b/test/hotCases/esm-dependency-import/import-meta-webpack-hot/module.js new file mode 100644 index 000000000..4989d996f --- /dev/null +++ b/test/hotCases/esm-dependency-import/import-meta-webpack-hot/module.js @@ -0,0 +1,5 @@ +import {value} from "dep1"; + +export const val = value; + +import.meta.webpackHot.accept("dep1"); diff --git a/test/hotCases/errors/esm-dependency-import/node_modules/dep1/exports.js b/test/hotCases/esm-dependency-import/import-meta-webpack-hot/node_modules/dep1/exports.js similarity index 100% rename from test/hotCases/errors/esm-dependency-import/node_modules/dep1/exports.js rename to test/hotCases/esm-dependency-import/import-meta-webpack-hot/node_modules/dep1/exports.js diff --git a/test/hotCases/esm-dependency-import/import-meta-webpack-hot/node_modules/dep1/file.js b/test/hotCases/esm-dependency-import/import-meta-webpack-hot/node_modules/dep1/file.js new file mode 100644 index 000000000..5b2c52ba4 --- /dev/null +++ b/test/hotCases/esm-dependency-import/import-meta-webpack-hot/node_modules/dep1/file.js @@ -0,0 +1,3 @@ +export var value = 1; +--- +export var value = 2; diff --git a/test/hotCases/errors/esm-dependency-import/node_modules/dep1/main.js b/test/hotCases/esm-dependency-import/import-meta-webpack-hot/node_modules/dep1/main.js similarity index 100% rename from test/hotCases/errors/esm-dependency-import/node_modules/dep1/main.js rename to test/hotCases/esm-dependency-import/import-meta-webpack-hot/node_modules/dep1/main.js diff --git a/test/hotCases/errors/esm-dependency-import/node_modules/dep1/package.json b/test/hotCases/esm-dependency-import/import-meta-webpack-hot/node_modules/dep1/package.json similarity index 100% rename from test/hotCases/errors/esm-dependency-import/node_modules/dep1/package.json rename to test/hotCases/esm-dependency-import/import-meta-webpack-hot/node_modules/dep1/package.json diff --git a/test/hotCases/errors/esm-dependency-import/index.js b/test/hotCases/esm-dependency-import/module-hot/index.js similarity index 83% rename from test/hotCases/errors/esm-dependency-import/index.js rename to test/hotCases/esm-dependency-import/module-hot/index.js index e684b2a68..472d82759 100644 --- a/test/hotCases/errors/esm-dependency-import/index.js +++ b/test/hotCases/esm-dependency-import/module-hot/index.js @@ -1,6 +1,6 @@ import {val} from "./module"; -it("should fail import a changed chunk using module.hot.accept API", (done) => { +it("should fail accept changes", (done) => { expect(val).toBe(1); NEXT(require("../../update")((err) => { try { diff --git a/test/hotCases/errors/esm-dependency-import/module.js b/test/hotCases/esm-dependency-import/module-hot/module.js similarity index 100% rename from test/hotCases/errors/esm-dependency-import/module.js rename to test/hotCases/esm-dependency-import/module-hot/module.js diff --git a/test/hotCases/esm-dependency-import/module-hot/node_modules/dep1/exports.js b/test/hotCases/esm-dependency-import/module-hot/node_modules/dep1/exports.js new file mode 100644 index 000000000..5309d4e57 --- /dev/null +++ b/test/hotCases/esm-dependency-import/module-hot/node_modules/dep1/exports.js @@ -0,0 +1 @@ +export {value} from "./file"; diff --git a/test/hotCases/esm-dependency-import/module-hot/node_modules/dep1/file.js b/test/hotCases/esm-dependency-import/module-hot/node_modules/dep1/file.js new file mode 100644 index 000000000..5b2c52ba4 --- /dev/null +++ b/test/hotCases/esm-dependency-import/module-hot/node_modules/dep1/file.js @@ -0,0 +1,3 @@ +export var value = 1; +--- +export var value = 2; diff --git a/test/hotCases/esm-dependency-import/module-hot/node_modules/dep1/main.js b/test/hotCases/esm-dependency-import/module-hot/node_modules/dep1/main.js new file mode 100644 index 000000000..d4321ac5b --- /dev/null +++ b/test/hotCases/esm-dependency-import/module-hot/node_modules/dep1/main.js @@ -0,0 +1,5 @@ +(() => { + throw new Error("should not resolve"); +})(); + +export default 1; diff --git a/test/hotCases/esm-dependency-import/module-hot/node_modules/dep1/package.json b/test/hotCases/esm-dependency-import/module-hot/node_modules/dep1/package.json new file mode 100644 index 000000000..0f01e7fa4 --- /dev/null +++ b/test/hotCases/esm-dependency-import/module-hot/node_modules/dep1/package.json @@ -0,0 +1,6 @@ +{ + "exports": { + "import": "./exports.js", + "default": "./main.js" + } +}