From 13590cd202d94144b47f756fc2eb781d0250e0b7 Mon Sep 17 00:00:00 2001 From: Christopher Beam Date: Mon, 24 Sep 2018 14:52:22 -0400 Subject: [PATCH 1/3] docs(config) add comments and values for rule.type --- src/content/configuration/module.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/content/configuration/module.md b/src/content/configuration/module.md index e473ae169be7..199ef3142174 100644 --- a/src/content/configuration/module.md +++ b/src/content/configuration/module.md @@ -264,6 +264,29 @@ Indicate what parts of the module contain side effects. See [Tree Shaking](/guid `Rule.test` is a shortcut to `Rule.resource.test`. If you supply a `Rule.test` option, you cannot also supply a `Rule.resource`. See [`Rule.resource`](#rule-resource) and [`Condition.test`](#condition) for details. +## `Rule.type` + +Possible values: `"javascript/auto" | "javascript/dynamic" | "javascript/esm" | "json" | "webassembly/experimental"` + +`Rule.type` sets the type for a matching module. This prevents defaultRules and their default importing behaviors from occuring. For example, if you want to load a `.json` file through a custom loader, you'd need to set the `type` to `javascript/auto` to bypass webpack's built-in json importing. (See [v4.0 changelog](https://github.com/webpack/webpack/releases/tag/v4.0.0) for more details) + +```javascript +module.exports = { + //... + module: { + rules: [ + //... + { + test: /\.json$/, + type: 'javascript/auto', + loader: 'custom-json-loader' + } + ] + } +}; +``` + + ## `Rule.use` A list of [UseEntries](#useentry) which are applied to modules. Each entry specifies a loader to be used. From 1fc4577a1482e9ee39444b43e0e437fe6f182ec5 Mon Sep 17 00:00:00 2001 From: Christopher Beam Date: Mon, 24 Sep 2018 14:56:20 -0400 Subject: [PATCH 2/3] updated contributors --- src/content/configuration/module.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/content/configuration/module.md b/src/content/configuration/module.md index 199ef3142174..1f8c6a9c3fc8 100644 --- a/src/content/configuration/module.md +++ b/src/content/configuration/module.md @@ -10,6 +10,7 @@ contributors: - byzyk - pnevares - fadysamirsadek + - nerdkid93 --- These options determine how the [different types of modules](/concepts/modules) within a project will be treated. From f8b8cd3cc14368943f792bf6164527cd24b19107 Mon Sep 17 00:00:00 2001 From: Christopher Beam Date: Wed, 26 Sep 2018 18:16:54 -0400 Subject: [PATCH 3/3] fix typo --- src/content/configuration/module.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/configuration/module.md b/src/content/configuration/module.md index 1f8c6a9c3fc8..7ea473dc3f1f 100644 --- a/src/content/configuration/module.md +++ b/src/content/configuration/module.md @@ -269,7 +269,7 @@ Indicate what parts of the module contain side effects. See [Tree Shaking](/guid Possible values: `"javascript/auto" | "javascript/dynamic" | "javascript/esm" | "json" | "webassembly/experimental"` -`Rule.type` sets the type for a matching module. This prevents defaultRules and their default importing behaviors from occuring. For example, if you want to load a `.json` file through a custom loader, you'd need to set the `type` to `javascript/auto` to bypass webpack's built-in json importing. (See [v4.0 changelog](https://github.com/webpack/webpack/releases/tag/v4.0.0) for more details) +`Rule.type` sets the type for a matching module. This prevents defaultRules and their default importing behaviors from occurring. For example, if you want to load a `.json` file through a custom loader, you'd need to set the `type` to `javascript/auto` to bypass webpack's built-in json importing. (See [v4.0 changelog](https://github.com/webpack/webpack/releases/tag/v4.0.0) for more details) ```javascript module.exports = {