実際に既にwebpackのProvidePlugin設定で設定されている未解決の変数について、typescriptコンパイラが起動した後、WebPackの構築プロセスが失敗するのを防ぐ方法はありますか?WebpackのProvidePluginで宣言されている未解決の変数に対してTypeScriptがWebpack構築を中断するのを防ぐにはどうすればいいですか?
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"declaration": false
},
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}
https://webpack.github.io/docs/list-of-plugins.html#provideplugin
tsconfig.json
webpack.config.js
plugins: [
...
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery",
"_": "underscore",
"underscore": "underscore"
//'process.env.NODE_ENV': '"development"'
}),
]
私の経験から、typescriptですが、変数が注入されるのを認識しません結果としてビルドは完了しません。
これは、ビルドの出力
ERROR in ./src/file1.component.ts
(77,9): error TS2304: Cannot find name '$'.
ERROR in ./src/file2.component.ts
(78,13): error TS2304: Cannot find name '$'.
ERROR in ./src/file3.ts
(155,15): error TS2304: Cannot find name 'jQuery'.
ERROR in ./src/file4.ts
(108,9): error TS2304: Cannot find name '$'.