Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12831 from animecyc/bugfix/shared-plugin-runtime-bug
fix: use runtime globals in shared plugin
- Loading branch information
Showing
8 changed files
with
142 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 'common-lib' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import value, { getValue } from "./module"; | ||
|
||
it("should accept a shared dependency", async () => { | ||
expect(value).toBe("module"); | ||
await expect(getValue()).resolves.toHaveProperty("default", "module"); | ||
module.hot.accept("./module"); | ||
|
||
await new Promise((resolve, reject) => | ||
NEXT(require("../../update")(reject, true, resolve)) | ||
); | ||
|
||
expect(value).toBe("common-lib"); | ||
await expect(getValue()).resolves.toHaveProperty("default", "common-lib"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default "module" | ||
|
||
export const getValue = () => Promise.resolve({ default: "module" }); | ||
--- | ||
export { default } from "common" | ||
|
||
export const getValue = () => import("common2"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// eslint-disable-next-line node/no-unpublished-require | ||
const { SharePlugin } = require("../../../../").sharing; | ||
|
||
/** @type {import("../../../../").Configuration} */ | ||
module.exports = { | ||
mode: "development", | ||
devtool: false, | ||
plugins: [ | ||
new SharePlugin({ | ||
shared: { | ||
common: { | ||
eager: true, | ||
import: "./common?1", | ||
requiredVersion: "1.1.1" | ||
}, | ||
common2: { | ||
import: "./common?2", | ||
requiredVersion: "1.1.1" | ||
} | ||
} | ||
}) | ||
] | ||
}; |