Comments (10)
I have no idea if this is relevant, but can it be that there is an issue in path resolving? As the server side console is reporting files to be watched with full path's, the client is talking in relative from project root, while we are accepting
relative from the current file? (routes.js
)
server console output
# removed unrelated files, but dit not change order
[gadicc:hot] Accelerator (xb5): Got fileData from
gadicc:ecmascript-hot/compile-ecmascript-hot (y6N), watching:
c:\dev\try-ecmascript-hot\src\client\lib\_reactHotLoader.js,
c:\dev\try-ecmascript-hot\src\client\modules\core\components\main_layout.js,
c:\dev\try-ecmascript-hot\src\client\modules\core\containers\main_layout.js,
c:\dev\try-ecmascript-hot\src\client\modules\profiles\actions\index.js,
c:\dev\try-ecmascript-hot\src\client\modules\profiles\actions\profiles.js,
c:\dev\try-ecmascript-hot\src\client\modules\profiles\components\list.js,
c:\dev\try-ecmascript-hot\src\client\modules\profiles\containers\list.js,
c:\dev\try-ecmascript-hot\src\client\modules\profiles\locales\index.js,
c:\dev\try-ecmascript-hot\src\client\modules\profiles\reducers\index.js,
c:\dev\try-ecmascript-hot\src\client\modules\profiles\reducers\list.js,
c:\dev\try-ecmascript-hot\src\client\modules\profiles\index.js,
c:\dev\try-ecmascript-hot\src\client\modules\profiles\routes.js,
c:\dev\try-ecmascript-hot\src\client\configs\context.js,
c:\dev\try-ecmascript-hot\src\client\configs\redux.js,
c:\dev\try-ecmascript-hot\src\meteor.startup.js,
c:\dev\try-ecmascript-hot\src\client\main.js
A second thing I noticed, should the stack
not also include /src/client/modules/profiles/routes.js
? As that is the file where I define what files to accept
for hot reload?
from meteor-hmr.
Yes, you're right. Unless I missed something, this looks like a bug. Can you try pass module.hot.accept
a file at a time (vs the array), and also maybe with the .js
at the end? Just some things that come to mind that could be broken here. Surprising though, it all looks good.
Don't worry, the watch paths on the server don't affect anything on the client. On the client, relative paths should correctly resolve to complete module ids. If you're really interested, you could take a look at the hot
global and see how we store everything, maybe it will make more sense :> (On that note, if your app is cloneable, or available online, I could take a look).
Once this is working though, I feel like you actually need to use the updated modules in your accept function, but do vaguely recall that with mantra we did something hacky like this and it still worked, but I think that was with the old version of react-hot-loader? Anyways, one thing at a time :>
from meteor-hmr.
I've tried a few different ways of accepting
, but none of them worked:
if (module.hot) {
const files = [
'./containers/list',
'./containers/list.js',
'/src/client/modules/profiles/containers/list',
'/src/client/modules/profiles/containers/list.js',
]
// tried 4 times while incrementing this 0,
module.hot.accept(files[0], function () {
localRouter._current.route._action(localRouter._current.params);
});
}
If I look at the console to what modules are loaded, I see the following result:
Object.keys(hot.allModules).filter(x =>
x.indexOf('/profiles/') > -1
)
// left some files out to keep it clear
[
"/src/client/modules/profiles/components",
"/src/client/modules/profiles/components/list.js",
"/src/client/modules/profiles/containers",
"/src/client/modules/profiles/containers/list.js",
"/src/client/modules/profiles/index.js",
"/src/client/modules/profiles/routes.js"
]
I'm not sure if this means anything, but the files I'm accepting
are in the allModules
object. I guess that's where you determine if it's okay to hot load it?
Unfortunately this repo is not clone-able. If really necessary I can take a look if I can minimize it to a reproduction.
from meteor-hmr.
@gadicc, to make things easier; I've stripped down my app till the last reproducible bit. You'll find it in the repo linked below. The containers
are nothing more than pipe-troughs. Import and export from the Components
. I did this purely to leave the structure of my app intact.
There is a start.bat
file that I use to startup my meteor app's so they are connected to a local database. I have the same issue when I just run meteor
from the command line. So that is something you can ignore.
https://github.com/smeijer/meteor-hmr-issue-126
from meteor-hmr.
Moving the src/client/modules
folder to imports/modules
makes the thing work. According to the documentation it should work as well without using the imports
folder, given the 'hack' provided above by going trough FlowRouter
is implemented correctly.
I guess this is not the case? Is this something you want to support, or should we just put all the stuff in the imports
dir?
I wish meteor had an --no-auto-resolve
or --strict-import
switch.
from meteor-hmr.
Hey, first off, thanks for the minimalist reproduction! Super helpful to be able to look at the running site.
Next off, an apology; I should have clicked a lot sooner on this one. meteor-hmr relies on meteor's import scanner, that is, for Meteor to work out which files import which files. You can verify this by viewing-source, loading up the app.js
, and searching for routes.js
module signature:
}],"routes.js":["react","react-mounter","react-hot-loader","../core/components/error_reporter",function(require,exports,module){
The array elements up until the module are the dependencies; as you can see, according to Meteor, routes.js does not import src/client/modules/profiles/routes.js
.
This is because for the static analysis to work, dynamic module names are not possible. What's always guaranteed to work is a pure text string, although some import scanners can handle simple concatenation and constant resolution - I'm not sure of the exact specifics of Meteor/reify though.
Anyway, I confirmed that using strings instead of constants in the require lines does indeed work as expected, i.e.
- const Layout = require(CONTAINERS.MAIN_LAYOUT).default;
+ const Layout = require('../core/containers/main_layout').default;
- const ProfileList = require(CONTAINERS.PROFILE_LIST).default;
+ const ProfileList = require('./containers/list').default;
Since module.hot.accept()
happens in the browser runtime, it doesn't have this requirement.
If you're saying that everything worked in imports
even with constants, I guess there are some special rules about the imports vs non-imports dirs in Meteor's import scanner.
Once again, thanks for the reproduction and the time you spent working on this yourself!
from meteor-hmr.
Marking as invalid
just because this is out of our control and isn't an issue with the meteor-hmr code.
from meteor-hmr.
Mmm, OTOH, I do wonder if we could keep track of require()
calls in the client runtime to augment the dependency chain we get from Meteor. It's not something I'd have any time to work on for quite some time though :/
from meteor-hmr.
Just to make this complete, so there are no misunderstandings.
If you're saying that everything worked in imports even with constants,
Well.. Not totally. At first the files weren't included in the build at all. Meteor simply did not detect them as being required.
Then I only added an import statement at the top. And left the rest unchanged. From that moment it worked. So yes, the require
is by using a constant. But the file has been import
ed at the top of the file.
from meteor-hmr.
Oh yeah, sure... as long as there's at least one explicit import somewhere, it will work (you could likewise add the import line to your files outside of the imports
directory).
from meteor-hmr.
Related Issues (20)
- Check for NODE_ENV !== 'development' and not NODE_ENV === 'production' HOT 7
- When in package but not app: "Arguments to path.join must be strings"
- Redbox problem HOT 2
- [Windows] [beta.6] .babelrc path error HOT 6
- [Windows] [beta.4] Random websockets error HOT 1
- Not working with Meteor 1.3.3.1 HOT 4
- [2.0.0-beta.6] Wrong file getting hot-reloaded HOT 1
- [2.0.0-beta.6] Getting into an infinite loop
- Refused to load the script 'http://localhost:3002/hot.js HOT 9
- Uncaught RangeError: Maximum call stack size exceeded
- Track dynamic require() calls to augment import chain
- Failed to parse SourceMap: http://localhost:3000/packages/f6ecec4bc04452452b12b571877bd3802b84f242.map
- Seems to rely on settings.json when run in Cordova HOT 10
- "Uncaught TypeError: Cannot read property '_collection' of undefined" when run in Cordova
- Path must be a string
- reloading-related WebSock problem stops meteor from booting HOT 1
- Doesn't work with Meteor 1.4.1.2 HOT 27
- Conflict: Constraint [email protected] is not satisfied by babel-runtime 1.0.1. HOT 3
- Info for potential maintainers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meteor-hmr.