-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HMR full reload #1417
Comments
That's weird, it should not do that.. something's odd about your setup, possibly you config or the components or something in between. Can you share more details and code samples? |
I am having the same issue, and am having trouble reproducing it in a smaller test case that I can share. I am using full control mode with the webpack config, and have a custom Here's the best JSON dump I can do for our full webpack config, with paths and names redacted: {
"devtool": "cheap-module-source-map",
"entry": {
"manager": [
"/Users/<redacted>/workspaces/<redacted>/node_modules/@storybook/react/dist/server/addons.js",
"/Users/<redacted>/workspaces/<redacted>/node_modules/@storybook/react/dist/server/config/polyfills.js",
"/Users/<redacted>/workspaces/<redacted>/node_modules/@storybook/react/dist/client/manager/index.js"
],
"preview": [
"/Users/<redacted>/workspaces/<redacted>/node_modules/@storybook/react/dist/server/config/polyfills.js",
"/Users/<redacted>/workspaces/<redacted>/node_modules/@storybook/react/dist/server/config/globals.js",
"/Users/<redacted>/workspaces/<redacted>/node_modules/webpack-hot-middleware/client.js?reload=true",
"/Users/<redacted>/workspaces/<redacted>/.storybook/config.js"
]
},
"externals": [
null
],
"module": {
"rules": [
{
"test": {},
"loader": "/Users/<redacted>/workspaces/<redacted>/node_modules/babel-loader/lib/index.js",
"query": {
"cacheDirectory": "/Users/<redacted>/workspaces/<redacted>/node_modules/.cache/react-storybook",
"presets": [
[
"env",
{
"loose": true,
"modules": "umd",
"targets": {
"uglify": false,
"browsers": [
"last 2 versions",
"ie >= 7"
]
}
}
],
"react"
],
"plugins": [
"transform-export-extensions",
"transform-class-properties",
"transform-decorators-legacy",
"transform-object-rest-spread",
[
"/Users/<redacted>/workspaces/<redacted>/node_modules/babel-plugin-react-docgen/lib/index.js",
{
"DOC_GEN_COLLECTION_NAME": "STORYBOOK_REACT_CLASSES"
}
]
],
"env": {
"test": {
"plugins": [
"istanbul"
],
"presets": [
[
"env",
{
"loose": true,
"modules": "umd",
"targets": {
"node": true
}
}
],
"react"
]
}
},
"sourceMaps": "both",
"babelrc": false
},
"include": [
"/Users/<redacted>/workspaces/<redacted>"
],
"exclude": [
"/Users/<redacted>/workspaces/<redacted>/node_modules"
]
},
{
"test": {},
"use": [
{
"loader": "style-loader",
"options": {
"sourceMap": true,
"singleton": true
}
},
{
"loader": "css-loader",
"options": {
"sourceMap": true
}
},
{
"loader": "postcss-loader",
"options": {
"sourceMap": true
}
},
{
"loader": "fast-sass-loader",
"options": {
"sourceMap": true,
"importer": [
null
],
"includePaths": [
"/Users/<redacted>/workspaces/<redacted>/packages",
"/Users/<redacted>/workspaces/<redacted>/node_modules",
"/Users/<redacted>",
"/node_modules"
]
}
}
],
"exclude": {}
},
{
"test": {},
"use": [
"svg-sprite-loader?{\"name\":\"<redacted>-icon-[name]\"}",
{
"loader": "svgo-loader",
"options": {
"plugins": [
{
"mergePaths": true
},
{
"removeTitle": true
},
{
"removeDesc": true
},
{
"removeXMLNS": true
},
{
"transformsWithOnePath": true
},
{
"removeDimensions": true
},
{
"removeAttrsWithValue": {
"type": "perItem",
"description": "Remove attribute/value pairs on match.",
"params": {
"attrs": [
[
"fill",
"<redacted>"
],
[
"fill",
"<redacted>"
]
]
}
}
}
]
}
}
]
},
{
"test": {},
"loaders": [
{
"loader": "style-loader",
"options": {
"sourceMap": true,
"singleton": true
}
},
{
"loader": "css-loader",
"options": {
"sourceMap": true
}
},
{
"loader": "postcss-loader",
"options": {
"sourceMap": true
}
}
]
},
{
"test": {},
"loader": "json-loader"
},
{
"test": {},
"loader": "expose?WaveSurfer"
}
]
},
"output": {
"path": "/Users/<redacted>/workspaces/<redacted>/node_modules/@storybook/react/dist/server/config/dist",
"filename": "static/[name].bundle.js",
"publicPath": "/"
},
"plugins": [
{
"preferEntry": true
},
{
"definitions": {
"process.env": {
"NODE_ENV": "\"development\""
}
}
},
{
"options": {
"options": {
"context": "/Users/<redacted>/workspaces/<redacted>/src",
"output": {
"path": "/Users/<redacted>/workspaces/<redacted>/dist"
}
},
"test": {}
}
},
{
"definitions": {
"process.env": {
"NODE_ENV": "\"development\"",
"PUBLIC_URL": "\"\"",
"STORYBOOK_GIT_ORIGIN": "\"git@github.com:<redacted>.git\"",
"STORYBOOK_GIT_BRANCH": "\"<redacted>\""
}
}
},
{
"fullBuildTimeout": 200
},
{
"options": {},
"pathCache": {},
"fsOperations": 0,
"primed": false
},
{
"nodeModulesPath": "/Users/<redacted>/workspaces/<redacted>/node_modules"
},
{}
],
"resolve": {
"modules": [
"node_modules",
"/Users/<redacted>/workspaces/<redacted>",
"/Users/<redacted>/workspaces/<redacted>/src",
"/Users/<redacted>/workspaces/<redacted>/node_modules",
"/Users/<redacted>",
"/Users/<redacted>/node_modules",
"/Users/<redacted>/workspaces/<redacted>/packages/<redacted>/src",
"/Users/<redacted>/workspaces/<redacted>/packages/<redacted>/src",
"/Users/<redacted>/workspaces/<redacted>/packages/<redacted>/src",
"/Users/<redacted>/workspaces/<redacted>/packages/<redacted>/src",
"/Users/<redacted>/workspaces/<redacted>/packages/<redacted>/src",
"/Users/<redacted>/workspaces/<redacted>/packages/<redacted>/src",
"/Users/<redacted>/workspaces/<redacted>/packages/<redacted>/src",
"/Users/<redacted>/workspaces/<redacted>/packages/<redacted>/src",
"/Users/<redacted>/workspaces/<redacted>/packages/<redacted>/src",
"/Users/<redacted>/workspaces/<redacted>/packages/<redacted>/src",
"/Users/<redacted>/workspaces/<redacted>/packages/<redacted>/src",
"/Users/<redacted>/workspaces/<redacted>/packages/<redacted>/src",
"/Users/<redacted>/workspaces/<redacted>/packages/<redacted>/src"
],
"alias": {
"<redacted>": "/Users/<redacted>/workspaces/<redacted>/packages/<redacted>/src/index.js",
"<redacted>": "/Users/<redacted>/workspaces/<redacted>/packages/<redacted>/src/index.js",
"<redacted>": "/Users/<redacted>/workspaces/<redacted>/packages/<redacted>",
"<redacted>": "/Users/<redacted>/workspaces/<redacted>/packages/<redacted>/src/index.js",
"<redacted>": "/Users/<redacted>/workspaces/<redacted>/packages/<redacted>/src/index.js",
"<redacted>": "/Users/<redacted>/workspaces/<redacted>/packages/<redacted>/src/index.js",
"<redacted>": "/Users/<redacted>/workspaces/<redacted>/packages/<redacted>",
"<redacted>": "/Users/<redacted>/workspaces/<redacted>/packages/<redacted>",
"<redacted>": "/Users/<redacted>/workspaces/<redacted>/packages/<redacted>/src/index.js",
"<redacted>": "/Users/<redacted>/workspaces/<redacted>/packages/<redacted>/src/index.js",
"<redacted>": "/Users/<redacted>/workspaces/<redacted>/packages/<redacted>/src/_main.scss",
"<redacted>": "/Users/<redacted>/workspaces/<redacted>/packages/<redacted>/src/index.js",
"<redacted>": "/Users/<redacted>/workspaces/<redacted>/packages/<redacted>",
"<redacted>": "/Users/<redacted>/workspaces/<redacted>/packages/<redacted>/src/index.js"
}
},
"performance": {
"hints": false
}
} and {
"presets": [
[
"env",
{
"loose": true,
"modules": "umd",
"targets": {
"uglify": false,
"browsers": [
"last 2 versions",
"ie >= 7"
]
}
}
],
"react"
],
"plugins": [
"transform-export-extensions",
"transform-class-properties",
"transform-decorators-legacy",
"transform-object-rest-spread"
],
"env": {
"test": {
"plugins": [
"istanbul"
],
"presets": [
[
"env",
{
"loose": true,
"modules": "umd",
"targets": {
"node": true
}
}
],
"react"
]
}
},
"sourceMaps": "both"
} When I update a file, I get the following messages:
I realize this is a very complicated setup. It has been working great for us until recently. I have not been able to determine why it thinks none of our components know how to hot reload. Any thoughts on things to try? |
I've looked through your configs and nothing spots my eye of what could be causing it. Are you passing the module instance to the storiesOf('The best component', module)
.add('in the best state', () => {
// ...
}); |
Yup, we're passing |
I am seeing this as well, I think it may be due to passing '?reload=true' as an argument webpack-hot-middleware? Not sure why that is being done? |
@frankwallis i experience the issue even after manually removing |
@frankwallis @joefraley Can confirm. Removing that flag appears to make no difference. |
I think we accidentally fixed it on our install by removing |
@kirkstrobeck do you mean using only |
Hey @joefraley
I hope that addresses your question, not sure if it does though. |
FWIW, I have actually now fixed this issue. The fix was to put a module.hot.accept at the entry of our story loader file, and I just have it reload the stories at that point. Works well, as far as I can tell... I'll just dump our whole loader script here, in case it helps others (we use lerna, hence the packages stuff): require('babel-register');
import configureStorybook from './configurator';
import '../src';
__webpack_public_path__ = 'http://localhost:9000/';
function loadStory(loader, key) {
if (!/node_modules/.test(key)) {
performance.mark(`start-${key}`);
loader(key);
performance.mark(`end-${key}`);
performance.measure(key, `start-${key}`, `end-${key}`);
}
}
function loadStories() {
const inSrc = require.context('../packages', true, /\bstories\.js$/);
inSrc.keys().forEach(loadStory.bind(this, inSrc));
const stories = require.context('../stories', false, /.js$/);
stories.keys().forEach(loadStory.bind(this, stories));
console.table(performance.getEntriesByType("measure"), ['name', 'duration']);
performance.clearMarks();
performance.clearMeasures();
}
configureStorybook(loadStories);
if (module.hot) {
module.hot.accept(() => configureStorybook(loadStories));
} |
Hi! I have the same problem, but on Angular. When I change something slightly, the input fields of my simple component get cleared, and the whole state is lost. |
const req = require.context("../lib", true, /.stories.js$/); function loadStories() { configure(loadStories, module); if (module.hot) { |
My page seems to do a full reload instead of HMR/live reload. It appears that the
config
file in indicated as updated when I am working with a component. I assume a small configuration change would fix this. Any insights would be helpful.Change file
[HMR] bundle rebuilding [HMR] bundle rebuilt in 2253ms [HMR] Checking for updates on the server... [HMR] Updated modules: [HMR] - ./filepath.js [HMR] - ./filepath.js$ [HMR] - ./storybook/config.js [HMR] App is up to date.
Relevant
package.json
snippetThe custom storybook config includes the following line:
It loads in the stories, so that may be part of the issue.
The text was updated successfully, but these errors were encountered: