Skip to content

Commit 2580661

Browse files
authored
Ignore warning when environment doesn't support async functions (#16)
1 parent 437acc8 commit 2580661

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/index.cts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ export class TransformAsyncModulesPlugin {
2626
}
2727

2828
apply(compiler: Compiler) {
29+
// Ignore the warning that environment won't support async
30+
(compiler.options.ignoreWarnings ??= []).push(
31+
(warning) => warning.name === "EnvironmentNotSupportAsyncWarning",
32+
);
33+
2934
// Pull some classes from the compiler's Webpack instance
3035
const { SourceMapSource } = compiler.webpack.sources;
3136
const { JavascriptModulesPlugin } = compiler.webpack.javascript;

test/goodbye.spec.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ const CHECK_CHUNKS = ["goodbye", "parent"] as const;
1414
for (const nodeVersion of [8, 6, 0.12]) {
1515
describe(`Goodbye delay with node ${nodeVersion} target`, function () {
1616
const outDir = join(context, "dist", `v${nodeVersion}`);
17-
let compileProblems = "";
17+
const configName = `goodbye-v${nodeVersion}`;
18+
let log: string | undefined;
1819

1920
before("Run Webpack", function (done) {
2021
this.timeout("5s");
2122
webpack(
2223
{
23-
name: `goodbye-node${nodeVersion}`,
24+
name: configName,
2425
context,
2526
entry: Object.fromEntries(
2627
ENTRY_NAMES.map((name) => [name, `./src/${name}.js`]),
@@ -43,16 +44,14 @@ for (const nodeVersion of [8, 6, 0.12]) {
4344
node: false,
4445
},
4546
(err, stats) => {
46-
if (stats?.hasErrors()) {
47-
compileProblems = stats.toString("errors-only");
48-
}
47+
log = stats?.toString("errors-warnings");
4948
done(err);
5049
},
5150
);
5251
});
5352

54-
it("Compiles without errors", async function () {
55-
expect(compileProblems, compileProblems).to.be.empty;
53+
it("Compiles without errors or warnings", async function () {
54+
expect(log, log).to.equal(`${configName} compiled successfully`);
5655
});
5756

5857
for (const name of CHECK_CHUNKS) {

0 commit comments

Comments
 (0)