Skip to content
This repository has been archived by the owner on May 17, 2019. It is now read-only.

Commit

Permalink
Fix --no-hmr flag
Browse files Browse the repository at this point in the history
#729

Co-authored-by: Mickey Burks <[email protected]>
Co-authored-by: Ryan Tsao <[email protected]>
  • Loading branch information
3 people authored and fusion-bot[bot] committed Mar 14, 2019
1 parent 28eebd8 commit bf1e1ce
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
9 changes: 6 additions & 3 deletions build/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ type CompilerType = {
type CompilerOpts = {
dir?: string,
env: "production" | "development",
hmr?: boolean,
watch?: boolean,
forceLegacyBuild?: boolean,
logger?: any,
Expand All @@ -100,6 +101,7 @@ function Compiler(
{
dir = '.',
env,
hmr = true,
forceLegacyBuild,
preserveNames,
watch = false,
Expand Down Expand Up @@ -132,17 +134,18 @@ function Compiler(

const sharedOpts = {
dir: root,
dev: env === 'development',
hmr,
watch,
state,
fusionConfig,
legacyPkgConfig,
preserveNames,
};

const dev = env === 'development';
const compiler = webpack([
getWebpackConfig({id: 'client-modern', dev, ...sharedOpts}),
getWebpackConfig({id: 'server', dev, ...sharedOpts}),
getWebpackConfig({id: 'client-modern', ...sharedOpts}),
getWebpackConfig({id: 'server', ...sharedOpts}),
]);

const statsLogger = getStatsLogger({dir, logger, env});
Expand Down
16 changes: 14 additions & 2 deletions build/get-webpack-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export type WebpackConfigOpts = {|
id: $Keys<typeof COMPILATIONS>,
dir: string,
dev: boolean,
hmr: boolean,
watch: boolean,
preserveNames: boolean,
state: {
Expand All @@ -96,7 +97,16 @@ export type WebpackConfigOpts = {|
module.exports = getWebpackConfig;

function getWebpackConfig(opts /*: WebpackConfigOpts */) {
const {id, dev, dir, watch, state, fusionConfig, legacyPkgConfig = {}} = opts;
const {
id,
dev,
dir,
hmr,
watch,
state,
fusionConfig,
legacyPkgConfig = {},
} = opts;
const main = 'src/main.js';

if (!fs.existsSync(path.join(dir, main))) {
Expand Down Expand Up @@ -193,11 +203,13 @@ function getWebpackConfig(opts /*: WebpackConfigOpts */) {
runtime === 'server' &&
path.join(__dirname, '../entries/server-public-path.js'),
dev &&
hmr &&
watch &&
runtime !== 'server' &&
`${require.resolve('webpack-hot-middleware/client')}?name=client`,
// TODO(#46): use 'webpack/hot/signal' instead
dev &&
hmr &&
watch &&
runtime === 'server' &&
`${require.resolve('webpack/hot/poll')}?1000`,
Expand Down Expand Up @@ -460,7 +472,7 @@ function getWebpackConfig(opts /*: WebpackConfigOpts */) {
*/
void 0
),
dev && watch && new webpack.HotModuleReplacementPlugin(),
dev && hmr && watch && new webpack.HotModuleReplacementPlugin(),
!dev && runtime === 'client' && new webpack.HashedModuleIdsPlugin(),
runtime === 'client' &&
// case-insensitive paths can cause problems
Expand Down
1 change: 1 addition & 0 deletions commands/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ exports.run = async function(
const compiler = new Compiler({
env: 'development',
dir,
hmr,
forceLegacyBuild,
watch: true,
logger,
Expand Down

0 comments on commit bf1e1ce

Please sign in to comment.