webpack-4

Can webpack 4 modules be configured as to allow Jasmine to spy on their members?

穿精又带淫゛_ 提交于 2019-11-30 07:25:37
问题 I've been unable to get my test jasmine test suite running with webpack 4. After upgrading webpack, I get the following error for almost every test: Error: <spyOn> : getField is not declared writable or has no setter This is due to a common pattern we use to create spys for simple functions is: import * as mod from 'my/module'; //... const funcSpy = spyOn(mod, 'myFunc'); I've played around with module.rules[].type but none of the options seem to do the trick. This webpack GH issue indicates

Webpack 4 universal library target

狂风中的少年 提交于 2019-11-29 16:43:49
问题 According to the Webpack 4 documentation, if I specify libraryTarget: 'umd' it should result in the following output: (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["MyLibrary"] = factory(); else root["MyLibrary"] = factory(); })(typeof self !== 'undefined' ? self : this,

Issues with getting started with webpack 4

我的未来我决定 提交于 2019-11-28 22:50:30
I am following the tutorial exactly as given here . But I am amazed that the docs seems outdated. e.g npx webpack src/index.js dist/bundle.js fails with: The CLI moved into a separate package: webpack-cli. Please install 'webpack-cli' in addition to webpack itself to use the CLI. -> When using npm: npm install webpack-cli -D -> When using yarn: yarn add webpack-cli -D If I install webpack-cli and try again I see this error: Hash: af9bc06fd641eb0ffd1e Version: webpack 4.0.0 Time: 3865ms Built at: 2018-2-26 05:10:45 1 asset Entrypoint main = main.js 1 (webpack)/buildin/module.js 519 bytes {0}

Webpack 4 - create vendor chunk

China☆狼群 提交于 2019-11-28 03:48:42
In a webpack 3 configuration I would use the code below to create separate vendor.js chunk: entry: { client: ['./client.js'], vendor: ['babel-polyfill', 'react', 'react-dom', 'redux'], }, output: { filename: '[name].[chunkhash].bundle.js', path: '../dist', chunkFilename: '[name].[chunkhash].bundle.js', publicPath: '/', }, plugins: [ new webpack.HashedModuleIdsPlugin(), new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', }), new webpack.optimize.CommonsChunkPlugin({ name: 'runtime', }), ], With all the changes I'm not sure how to do it with Webpack 4. I know that CommonChunksPlugin was

Webpack 4 migration CommonsChunkPlugin

爱⌒轻易说出口 提交于 2019-11-27 11:47:28
I need help migrating the following code from webpack 3 to 4. new webpack.optimize.CommonsChunkPlugin({ minChunks: module => module.context && module.context.indexOf("node_modules") !== -1, name: "vendor", chunks: ["main"] }) I have two entry files and want only the dependencies of the first one to be included in the vendor chunk. The dependencies of the second entry should all stay in its own bundle. Legends As of webpack v4 the CommonsChunkPlugin is deprecated. We have deprecated and removed CommonsChunkPlugin, and have replaced it with a set of defaults and easily overridable API called

Webpack 4 migration CommonsChunkPlugin

℡╲_俬逩灬. 提交于 2019-11-26 22:20:50
问题 I need help migrating the following code from webpack 3 to 4. new webpack.optimize.CommonsChunkPlugin({ minChunks: module => module.context && module.context.indexOf("node_modules") !== -1, name: "vendor", chunks: ["main"] }) I have two entry files and want only the dependencies of the first one to be included in the vendor chunk. The dependencies of the second entry should all stay in its own bundle. 回答1: As of webpack v4 the CommonsChunkPlugin is deprecated. We have deprecated and removed