Skip to content

Commit

Permalink
config.webpack: Add hot-accept-webpack-plugin (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
artembatura authored Feb 6, 2019
1 parent e9b0b72 commit c2c92cc
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 9 deletions.
6 changes: 4 additions & 2 deletions packages/config.webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@
"@zero-scripts/core": "^0.4.0",
"file-loader": "3.0.1",
"terser-webpack-plugin": "1.2.2",
"webpack-assets-manifest": "3.1.1"
"webpack-assets-manifest": "3.1.1",
"hot-accept-webpack-plugin": "1.1.1"
},
"devDependencies": {
"@types/node": "10.12.21",
"@types/webpack": "4.4.22",
"@types/webpack-assets-manifest": "3.0.0",
"@zero-scripts/ts-config": "^0.4.0",
"typescript": "3.3.1"
"typescript": "3.3.1",
"@types/terser-webpack-plugin": "1.2.0"
},
"peerDependencies": {
"webpack": ">=4.20.0"
Expand Down
16 changes: 13 additions & 3 deletions packages/config.webpack/src/createWebpackConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import {
} from 'webpack';
import { WebpackConfigOptions } from './WebpackConfigOptions';
import ManifestPlugin from 'webpack-assets-manifest';

const TerserPlugin = require('terser-webpack-plugin');
import { HotAcceptPlugin } from 'hot-accept-webpack-plugin';
import TerserPlugin from 'terser-webpack-plugin';
import path from 'path';

export const createWebpackConfiguration = ({
isDev,
Expand Down Expand Up @@ -57,7 +58,16 @@ export const createWebpackConfiguration = ({
new ManifestPlugin({
output: 'asset-manifest.json'
})
].concat(isDev ? [new HotModuleReplacementPlugin()] : []),
].concat(
isDev
? [
new HotModuleReplacementPlugin(),
new HotAcceptPlugin({
test: path.basename(paths.indexJs)
})
]
: []
),
node: {
module: 'empty',
dgram: 'empty',
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/helpers/extensionsRegex.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const extensionsRegex = (extensions: string[]) =>
new RegExp(`\\.(${extensions.join('|')})$`);
export const extensionsRegex = (extensions: string[], fileName: string = '') =>
new RegExp(`${fileName}\\.(${extensions.join('|')})$`);
107 changes: 105 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,11 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.18.tgz#1d3ca764718915584fcd9f6344621b7672665c67"
integrity sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==

"@types/[email protected]":
version "10.12.20"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.20.tgz#f79f959acd3422d0889bd1ead1664bd2d17cd367"
integrity sha512-9spv6SklidqxevvZyOUGjZVz4QRXGu2dNaLyXIFzFYZW0AGDykzPRIUFJXTlQXyfzAucddwTcGtJNim8zqSOPA==

"@types/[email protected]":
version "10.12.21"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.21.tgz#7e8a0c34cf29f4e17a36e9bd0ea72d45ba03908e"
Expand All @@ -1529,11 +1534,39 @@
dependencies:
"@types/webpack" "*"

"@types/prop-types@*":
version "15.5.8"
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.5.8.tgz#8ae4e0ea205fe95c3901a5a1df7f66495e3a56ce"
integrity sha512-3AQoUxQcQtLHsK25wtTWIoIpgYjH3vSDroZOUr7PpCHw/jLY1RB9z9E8dBT/OSmwStVgkRNvdh+ZHNiomRieaw==

"@types/q@^1.5.1":
version "1.5.1"
resolved "https://registry.yarnpkg.com/@types/q/-/q-1.5.1.tgz#48fd98c1561fe718b61733daed46ff115b496e18"
integrity sha512-eqz8c/0kwNi/OEHQfvIuJVLTst3in0e7uTKeuY+WL/zfKn0xVujOTp42bS/vUUokhK5P2BppLd9JXMOMHcgbjA==

"@types/[email protected]":
version "16.0.11"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.0.11.tgz#bd10ccb0d9260343f4b9a49d4f7a8330a5c1f081"
integrity sha512-x6zUx9/42B5Kl2Vl9HlopV8JF64wLpX3c+Pst9kc1HgzrsH+mkehe/zmHMQTplIrR48H2gpU7ZqurQolYu8XBA==
dependencies:
"@types/react" "*"

"@types/react@*":
version "16.8.1"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.8.1.tgz#b431b104ecc6febda170b718caa9f50be66a6750"
integrity sha512-tD1ETKJcuhANOejRc/p7OgQ16DKnbGi0M3LccelKlPnUCDp2a5koVxZFoRN9HN+A+m84HB5VGN7I+r3nNhS3PA==
dependencies:
"@types/prop-types" "*"
csstype "^2.2.0"

"@types/[email protected]":
version "16.7.22"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.7.22.tgz#5bc6d166d5ac34b835756f0b736c7b1af0043e81"
integrity sha512-j/3tVoY09kHcTfbia4l67ofQn9xvktUvlC/4QN0KuBHAXlbU/wuGKMb8WfEb/vIcWxsOxHv559uYprkFDFfP8Q==
dependencies:
"@types/prop-types" "*"
csstype "^2.2.0"

"@types/[email protected]":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/read-pkg/-/read-pkg-3.0.0.tgz#17ab6f0b396a58a5567ee387f558f2caedc8ae53"
Expand All @@ -1556,6 +1589,21 @@
resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.4.tgz#b4ffc7dc97b498c969b360a41eee247f82616370"
integrity sha512-78AdXtlhpCHT0K3EytMpn4JNxaf5tbqbLcbIRoQIHzpTIyjpxLQKRoxU55ujBXAtg3Nl2h/XWvfDa9dsMOd0pQ==

"@types/[email protected]":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@types/terser-webpack-plugin/-/terser-webpack-plugin-1.2.0.tgz#6fae45ab793d468b0af89c6662ad46104323e679"
integrity sha512-mTzZIJF0d0lEl5OEV+vD5H9ynV90XItllaoQlsb+GbNTaIlANj/oO0xbv/YCDoSlUKydWPCVFZxywDM86C450g==
dependencies:
"@types/terser" "*"
"@types/webpack" "*"

"@types/terser@*":
version "3.8.0"
resolved "https://registry.yarnpkg.com/@types/terser/-/terser-3.8.0.tgz#f4d218fd2175c4ccd9492e3edc388d17e0dd4da4"
integrity sha512-ocma0QDfEyyfgXrigbMd4lKS9cYM+1CurxNLGvwLUG3l1vBuRS6AgSYINBRR/+fR3yHzpO7xM/wcVLFgRCIAtQ==
dependencies:
source-map "*"

"@types/uglify-js@*":
version "3.0.4"
resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.0.4.tgz#96beae23df6f561862a830b4288a49e86baac082"
Expand Down Expand Up @@ -3519,6 +3567,11 @@ cssstyle@^1.0.0:
dependencies:
cssom "0.3.x"

csstype@^2.2.0:
version "2.6.2"
resolved "https://registry.yarnpkg.com/csstype/-/csstype-2.6.2.tgz#3043d5e065454579afc7478a18de41909c8a2f01"
integrity sha512-Rl7PvTae0pflc1YtxtKbiSqq20Ts6vpIYOD5WBafl4y123DyHUeLrRdQP66sQW8/6gmX8jrYJLXwNeMqYVJcow==

currently-unhandled@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea"
Expand Down Expand Up @@ -4673,7 +4726,7 @@ forever-agent@~0.6.1:
resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"
integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=

fork-ts-checker-webpack-plugin@~1.0.0-alpha.6:
fork-ts-checker-webpack-plugin@1.0.0-alpha.6, fork-ts-checker-webpack-plugin@~1.0.0-alpha.6:
version "1.0.0-alpha.6"
resolved "https://registry.yarnpkg.com/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-1.0.0-alpha.6.tgz#826c57048addf8a3253853615c84f3ff7beeaf45"
integrity sha512-s/V+58nLrUjuXyzYk8AL11XG8bxIirTbafDLMn26sL59HQx8QvvsRTqOkhq4MV0coIkog1jZuH/E9Abm8zFZ2g==
Expand Down Expand Up @@ -5166,6 +5219,13 @@ hosted-git-info@^2.1.4, hosted-git-info@^2.6.0:
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.7.1.tgz#97f236977bd6e125408930ff6de3eec6281ec047"
integrity sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==

[email protected]:
version "1.1.1"
resolved "https://registry.yarnpkg.com/hot-accept-webpack-plugin/-/hot-accept-webpack-plugin-1.1.1.tgz#4b611548b66c6f5855b88138e678087e93cc1a82"
integrity sha512-zOvPa/uNe7ek5wmqafLnRFVOxEmCOjGvI4XMImwiIztomjZlSzS1EBsHk2xgEOxUEoRdap95n3ygYlHjmZUPGA==
dependencies:
modify-source-webpack-plugin "1.0.0"

hsl-regex@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/hsl-regex/-/hsl-regex-1.0.0.tgz#d49330c789ed819e276a4c0d272dffa30b18fe6e"
Expand Down Expand Up @@ -6904,7 +6964,7 @@ log-update@^2.3.0:
cli-cursor "^2.0.0"
wrap-ansi "^3.0.1"

loose-envify@^1.0.0, loose-envify@^1.3.1:
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1:
version "1.4.0"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==
Expand Down Expand Up @@ -7278,6 +7338,11 @@ [email protected], [email protected], "mkdirp@>=0.5 0", mkdirp@^0.5, mkdirp@^0.5.0, mkdirp@^
dependencies:
minimist "0.0.8"

[email protected]:
version "1.0.0"
resolved "https://registry.yarnpkg.com/modify-source-webpack-plugin/-/modify-source-webpack-plugin-1.0.0.tgz#c44f42b041937323996b1ca4bdb872e1db3437aa"
integrity sha512-qVbLOmzVmTRzubBDjYKWVNosDEjGO3wFlniC7fOOiXBNKh60zOKXcwaX7IXK+QrQA31vIAsws41fPlhxq7eccg==

modify-values@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/modify-values/-/modify-values-1.0.1.tgz#b3939fa605546474e3e3e3c63d64bd43b4ee6022"
Expand Down Expand Up @@ -9123,6 +9188,26 @@ rc@^1.2.7:
minimist "^1.2.0"
strip-json-comments "~2.0.1"

[email protected]:
version "16.7.0"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.7.0.tgz#a17b2a7ca89ee7390bc1ed5eb81783c7461748b8"
integrity sha512-D0Ufv1ExCAmF38P2Uh1lwpminZFRXEINJe53zRAbm4KPwSyd6DY/uDoS0Blj9jvPpn1+wivKpZYc8aAAN/nAkg==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.2"
scheduler "^0.12.0"

[email protected]:
version "16.7.0"
resolved "https://registry.yarnpkg.com/react/-/react-16.7.0.tgz#b674ec396b0a5715873b350446f7ea0802ab6381"
integrity sha512-StCz3QY8lxTb5cl2HJxjwLFOXPIFQp+p+hxQfc8WE0QiLfCtIlKj8/+5tjjKm8uSTlAW+fCPaavGFS06V9Ar3A==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.2"
scheduler "^0.12.0"

read-cmd-shim@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/read-cmd-shim/-/read-cmd-shim-1.0.1.tgz#2d5d157786a37c055d22077c32c53f8329e91c7b"
Expand Down Expand Up @@ -9684,6 +9769,14 @@ sax@^1.2.4, sax@~1.2.4:
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==

scheduler@^0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.12.0.tgz#8ab17699939c0aedc5a196a657743c496538647b"
integrity sha512-t7MBR28Akcp4Jm+QoR63XgAi9YgCUmgvDHqf5otgAj4QvdoBE4ImCX0ffehefePPG+aitiYHp0g/mW6s4Tp+dw==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"

schema-utils@^0.4.4:
version "0.4.7"
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-0.4.7.tgz#ba74f597d2be2ea880131746ee17d0a093c68187"
Expand Down Expand Up @@ -9975,6 +10068,11 @@ source-map-url@^0.4.0:
resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3"
integrity sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=

source-map@*:
version "0.7.3"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383"
integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==

source-map@^0.4.2:
version "0.4.4"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b"
Expand Down Expand Up @@ -10702,6 +10800,11 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=

[email protected]:
version "3.2.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.2.4.tgz#c585cb952912263d915b462726ce244ba510ef3d"
integrity sha512-0RNDbSdEokBeEAkgNbxJ+BLwSManFy9TeXz8uW+48j/xhEXv1ePME60olyzw2XzUqUBNAYFeJadIqAgNqIACwg==

[email protected]:
version "3.3.1"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.3.1.tgz#6de14e1db4b8a006ac535e482c8ba018c55f750b"
Expand Down

0 comments on commit c2c92cc

Please sign in to comment.