-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Description
Bug report
What is the current behavior?
The documentation in https://webpack.js.org/guides/asset-modules/#replacing-inline-loader-syntax to replace inline loaders with Asset Modules does not apply to require.context. Specifically, it doesn't seem like I can exclude a source asset from being parsed by other loaders. This was possibly in webpack 4 with require.context("!raw-loader!./code", false, /\.js$/); but there seems to be no API for this behavior in webpack 5 i.e.
{
test: /\.m?js$/,
resourceQuery: /^(?!\?raw$).*/,
},
{
resourceQuery: /raw/,
type: "asset/source",
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ["babel-loader"],
},does result in transpiled source assets.
If the current behavior is a bug, please provide the steps to reproduce.
- Clone https://github.com/eps1lon/webpack-asset-modules-source-require-context
yarn install- `yarn start´
- Open page
The source code is printed transpiled (notice the /*#__PURE__*/React.createElement transpilation artifact).
What is the expected behavior?
The source asset is not transpiled (or parsed by any other loader for that matter).
Other relevant information:
webpack version: 5.21.1
Node.js version: 12.20.0
Operating System: Ubuntu 20.04.2 LTS
Additional tools:
The issue seems similar to #5730?