Comments (7)
Finally we figured a root cause - webpack in production mode does Module Concatenation (ModuleConcatenationPlugin enabled in production mode by default) which makes view model inlined into the class that uses it (If you refer to the same VM in multiple places it wouldn't happen).
So one line in webpack config fixes the problem:
optimization: {
concatenateModules: false,
},
Aurelia Webpack Plugin, we suppose, should somehow prevent inlining, like what it does when it processes Platform.moduleName'd module ref.
from dialog.
For this to work you will either need to pass the .view
(moduleId or ViewStrategy
) or use @view()
/static $view
on the view model class.
from dialog.
@useview('dialog/dialog.html') on dialog ViewModel fixes the problem, I it would be great to understand how production mode affects the runtime.
from dialog.
- production mode is quite broad - it varies between webpack, jspm, aurelia-cli and all their configuration options.
- Just to be clear, I suggested using
@view()
, not@useView()
. With@useView()
you are basically specifying the moduleId of the view to use. So if you are trying to move away from the use of moduleId this will not help.
from dialog.
- sorry for not making this clear, I referred to https://webpack.js.org/concepts/mode/#mode-production
- Unfortunately I wasn't able to find any documentation about @view, it's not the same as @inlineView? Could you provide me a link, please?
I think we just try to make Aurelia conventions work for the production webpack build.
from dialog.
I just stumbled across this issue a few moment ago.
The application I am working on is a mixed JS and TS. I have only noticed this problem occurring on view models which are typescript files. JS file seem to work just fine.
Hopefully, that sheds some light on this issue
from dialog.
@ggayowsky can you give this comment (a the comments after it as well, there's extra example) a look https://discourse.aurelia.io/t/production-build-issue/3774/3 and see if it's somewhat matches your scenario.
An explanation in our Discord chat at https://discord.com/channels/448698263508615178/448699089513611266/755368450058092555
PLATFORM.moduleName when used with webpack will tell Webpack to remove some optimization related to the module being referenced, which will ensures the export names are not mangled to a single letter, or removed entirely when modules are concatenated. If there's no module, Aurelia cannot figure out a view module from the view model, and will result in runtime error. What you can do, if you'd like to use import is use @inlineView, or @useview, or static view via static $view = '' The reason it works now for you, I'm guessing, is that you are in development build, which means webpack optimization not yet kicked in
from dialog.
Related Issues (20)
- Dialog VM hooks for keyboard (Enter/Escape) HOT 7
- Add class reference support for .viewModel HOT 4
- Plugin setting configurations not working HOT 1
- Error when building HOT 1
- AttachFocus is not the default export
- Bug: Lazy loading components causes unnecessary webpack chunks HOT 14
- Remove .rollupcache folder from npm package
- Cannot find name 'AddEventListenerOptions'. HOT 7
- Global callbacks / events every time a dialog opens / closes HOT 8
- Focus management on open / close HOT 5
- Typings fail to install HOT 1
- typings.json does not define dependency versions HOT 2
- DialogCloseError is not exposed in typings HOT 2
- Add whenConfirmed alongside whenClosed HOT 1
- Doesn't load template page in IE11 HOT 12
- null reference error on closing dialog
- Support typing the model with a generic type argument on the open method HOT 2
- dialog forces mulptiple chunks in webpack prod build HOT 1
- 404 on typings install for Aurelia metadata HOT 3
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 dialog.