Skip to content

node async wasm loader generates code using import.meta for commonjs #19209

@ashi009

Description

@ashi009

Bug report

What is the current behavior?

When bundling async wasm targeting node with specific version and commonjs, the generated code will use import.meta. Which is not valid under commonjs.

If the current behavior is a bug, please provide the steps to reproduce.

https://github.com/ashi009/wasm-webpack

npm i
npm run build
grep 'import.meta' dist/bundle.js 

What is the expected behavior?

no import.meta in the generated bundle.

this is a regression from
0016a1a#diff-191522664ed219f319b8f2a6ed831bc2888af7294dec2e57a0bd640c7b2e298d. Before this change the async-node and async-node-module are processed in different branches. Where output.environment.module is actually handled under the assumption that the module output is required.

Other relevant information:
webpack version: 5.97.1
Node.js version: 18.17
Operating System: macOS
Additional tools:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions