File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,44 @@ subdirectories. To enable this, set `includeNodeModules: true`.
103
103
104
104
Default: ` false ` .
105
105
106
+ ## Webpack 4 Compatibility
107
+
108
+ This plugin supports webpack versions 4.x and 5.x. However, there are some
109
+ caveats when using webpack 4.x in conjunction with ES modules.
110
+
111
+ Webpack 4.x does not support ` webpack.config ` files in ES module format, so if
112
+ you set ` "type": "module" ` in ` package.json ` then you must mark the
113
+ ` webpack.config ` file as a CommonJS file by naming it ` webpack.config.cjs `
114
+ (with a ` .cjs ` extension). Of course, you must also use CommonJS format, for
115
+ example:
116
+
117
+ ``` js
118
+ const ResolveTypeScriptPlugin = require (" resolve-typescript-plugin" );
119
+
120
+ module .exports = {
121
+ module: {
122
+ rules: [
123
+ {
124
+ test: / \. tsx? $ / ,
125
+ use: " ts-loader"
126
+ }
127
+ ]
128
+ },
129
+ resolve: {
130
+ plugins: [new ResolveTypeScriptPlugin ()]
131
+ }
132
+ };
133
+ ```
134
+
135
+ Webpack 4.x also will not discover the ` webpack.config ` file automatically if
136
+ it is named with a ` .cjs ` extension, so you must specify the path to the
137
+ configuration file explicitly when running webpack, for example:
138
+ ` webpack --config ./webpack.config.cjs ` .
139
+
140
+ Webpack 5.x has none of these caveats. In Webpack 5.x, configuration files may
141
+ be in ES Module or CommonJS format, and will be discovered automatically if
142
+ they are named with any of ` .js ` , ` .cjs ` , or ` .mjs ` file extensions.
143
+
106
144
## Feedback
107
145
108
146
We're seeking [ community feedback] [ 5 ] on this plugin.
You can’t perform that action at this time.
0 commit comments