-
-
Notifications
You must be signed in to change notification settings - Fork 607
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow require
webpack.config.js
in ESM format (#4346)
- Loading branch information
1 parent
3642966
commit 5106684
Showing
11 changed files
with
52 additions
and
20 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,18 @@ | ||
const { run } = require("../../../utils/test-utils"); | ||
|
||
describe("webpack cli", () => { | ||
it("should support mjs config format using `require`", async () => { | ||
const { exitCode, stdout } = await run(__dirname, ["-c", "webpack.config.js"]); | ||
|
||
const [major, minor] = process.versions.node.split(".").map(Number); | ||
|
||
if ((major >= 22 && minor >= 11) || major >= 23) { | ||
expect(exitCode).toBe(0); | ||
// stderr contains - Support for loading ES Module in require() is an experimental feature and might change at any time | ||
// expect(stderr).toBeFalsy(); | ||
expect(stdout).toBeTruthy(); | ||
} else { | ||
expect(exitCode).toBe(2); | ||
} | ||
}); | ||
}); |
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
test/build/config-format/esm-require-await/webpack.config.js
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,13 @@ | ||
import { fileURLToPath } from "url"; | ||
import path from "path"; | ||
|
||
const mode = await "development"; | ||
|
||
export default { | ||
mode, | ||
entry: "./main.js", | ||
output: { | ||
path: path.resolve(path.dirname(fileURLToPath(import.meta.url)), "dist"), | ||
filename: "foo.bundle.js", | ||
}, | ||
}; |
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,18 @@ | ||
const { run } = require("../../../utils/test-utils"); | ||
|
||
describe("webpack cli", () => { | ||
it("should support mjs config format using `require`", async () => { | ||
const { exitCode, stdout } = await run(__dirname, ["-c", "webpack.config.js"]); | ||
|
||
const [major, minor] = process.versions.node.split(".").map(Number); | ||
|
||
if ((major >= 22 && minor >= 11) || major >= 23) { | ||
expect(exitCode).toBe(0); | ||
// stderr contains - Support for loading ES Module in require() is an experimental feature and might change at any time | ||
// expect(stderr).toBeFalsy(); | ||
expect(stdout).toBeTruthy(); | ||
} else { | ||
expect(exitCode).toBe(2); | ||
} | ||
}); | ||
}); |
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 @@ | ||
console.log("You know who"); |
File renamed without changes.