webpack / webpack.js.org

Repository for webpack documentation and more!

Home Page:https://webpack.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Document webpack change: refactor: migrate on `acorn-import-attributes`

webpack-bot opened this issue · comments

A pull request by @alexander-akait was merged and maintainers requested a documentation change.

See pull request: webpack/webpack#18251


What kind of change does this PR introduce?

xtuc/acorn-import-attributes#31

Did you add tests for your changes?

Existing

Does this PR introduce a breaking change?

No

What needs to be documented once your changes are merged?

Added with ruleset rule, like assert, i.e.:

/** @type {import("../../../../").Configuration} */
module.exports = {
	module: {
		rules: [
			{
                                // will handle `pkg-1.json`
				assert: { type: "json" },
				loader: require.resolve("./loader-assert.js")
			},
			{
			        // will handle `pkg-2.json`
				with: { type: "json" },
				loader: require.resolve("./loader-with.js")
			}
		]
	}
};

```js
import one from "./pkg-1.json" assert { type: "json" };
import two from "./pkg-2.json" with { type: "json" };