-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
unable to use "lazy" in html, "Can't resolve 'bundle' #89
Comments
@jods4 should we switch to |
In any case, we should be careful when discussing because it can have different meanings:
I have not added this to reduce the complexity of v1 and because I'm unsure if this is really the idomatic webpack way to go about it:
Does it make sense to support My current thinking based on our discussions plus the examples @Vheissu gave me is that we should add some facilities to re-organize your code in various files (sync), and keep |
Thanks for responding to my issue! I got to know "lazy" usage from the document below:
In addition, with this plugin, seems that webpack (2.2.0) behaves in different way:
I wonder if they are expected behaviors with Aurelia-Webpack? |
Yes, in the old plugin
Latest experimental versions even accept
I think so. Potentially, you might be requiring quite a bit from the View, e.g. other Custom Elements, ValueConverters, BindingBehaviors.
Yes, but you might want to have a chunk for a set of ValueConverters, which is used by multiple views.
Agreed. This is how it worked till now in |
If the views are not in the same chunk to start with, that's exactly what I don't want to do the effort to think this through for v2.0, but we surely can adjust for a later release if we feel there is a need. It's certainly not a blocker. |
So, in lieu of doing something like this in the package.json:
how would we go about creating separate chunks for separate "pages/paths" of our application with Aurelia+Webpack? Some pages of my code use specific external vendor plugins that do not need to be loaded on the login page, for example. |
@nathanchase The second parameter to |
Woah. I've never seen |
@nathanchase that's all new for the upcoming 2.0 webpack plugins. |
Ah. Yeah, I've been waiting to see those release, but I'm not using TypeScript, and it seems like those experimental builds are all TS-based thus far. |
They work just the same in JS. |
The I have a custom element which I am hoping to achieve a similar outcome. Both approaches mentioned in the docs for webpack bundler don't seem to work:
With the centralized approach, my custom element appears to be bundled with the module that has a
The Will these methods eventually be supported, or are there alternative ways to achieve code splitting a custom element to load async on demand? |
I don't support What are you trying to achieve? If Aurelia encounters a The view itself can easily be lazy-loaded as you noted, along with the local resources it uses. Lazy loading is for stuff that you might not need, or might need later. By putting them in a different chunk you optimize the starting time of your page. A route is prime example of something you might need later -- maybe not at all. The local resource of a view is something you need right now when loading the view. It's not a good boundary point to perform lazy loading. |
I think the boundary would be better placed around yellow "child routed module" then. Until navigated to they are not loaded at all. If you want to put plugins used in more than one lazy route in a single chunk, you can use The hub docs are still for the 1.x plugins, sorry for the confusion. The new plugins are a complete rewrite and don't share much with the old ones. |
I think my understanding was still very vague when it came to when modules are loaded. The I think the only alternative to delay the loading of this library, without chunking my child modules, is to use dynamic import, with which I have granular control over when the resource is loaded. Much appreciated @jods4! |
You should check the behavior of your application but I don't think To actually delay load the expensive part, you need to make the at the pages that require it, which is easy enough. |
Yeah, I went with your suggestion and just set the boundary around my child plugin and then did a specific commons chunk for that expensive custom element. I'm guessing this is similar to how the old
Have I confirmed what you meant here? |
If by just set the boundary around my child plugin you meant child route, then yes! :) You can observe what is loaded and when in the network analyzer of your browser. It should be nice (route and expensive component are only loaded when navigating to the route, and only once). |
I'm submitting a bug report
1.2.0
Please tell us about your environment:
Operating System:
Windows 7
Node Version:
6.9.4
NPM Version:
3.10.10
Webpack AND Version
webpack 2.2.0
Browser:
all
Language:
TypeScript
Current behavior:
When I specify "lazy" to "require" tag in html.
<require from="./component/component" lazy></require>
And perform webpack bundle, no split bundle created, and can observe the following warning:
WARNING in ./src ^\.\/.*$ Module not found: Error: Can't resolve 'bundle' in 'C:\Users\Jin\IdeaProjects\TestAurelia\src' BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders. You need to specify 'bundle-loader' instead of 'bundle'. @ ./src ^\.\/.*$ @ ./~/aurelia-loader-webpack/dist/commonjs/aurelia-loader-webpack.js
Maybe the following source code at line 50 and 51
if (lazy || bundle) output +=
bundle?;
should be fixed to
if (lazy || bundle) output +=
bundle-loader?;
Expected/desired behavior:
chunk bundle should be created for my component, like 1.chunk.js, 2.chunk.js and etc ...
What is the expected behavior?
What is the motivation / use case for changing the behavior?
The text was updated successfully, but these errors were encountered: