Closed qraynaud closed 4 years ago
Thanks @qraynaud for opening this issue. This is strange as you said.
I took a moment to find out more about this problem and could reproduce it with a clean install from aurelia-cli@1.3.0
. Digging in the webpack.config.js
file I found that it comes from the following line:
devtool: production ? 'nosources-source-map' : 'cheap-module-eval-source-map',
You can replace by
devtool: 'cheap-module-eval-source-map',
To make it build successful but at the moment I don't know more than that. Will probably need help from someone who know more about building. Maybe @bigopon could point us in the right direction...
I'll try to reproduce this soon. Thanks for creating this issue
The issue you encountered with production build comes from this line https://github.com/aurelia/ux/blob/e223ca547856f5c199f3418170a4db2dad764f31/packages/form/src/index.ts#L13
In short, we use naming convention to help Aurelia determine the kind of resource (element/attribute/converter/etc...) a class is. In production build, however, webpack minify everything that is minify-able. This includes exports of modules that are not touched by PLATFORM.moduleName
or something equivalent deoptimization in webpack land. So for our ux-form
, the custom attribute name would be shortened to a single letter e
, and thus will be interpreted as custom element and thus, resulted in view not found for it.
Fix: we should decorate the UxSubmitCustomAttribute
with @customAttribute('ux-submit')
, or use static resource convention. https://aurelia.io/blog/2018/06/24/aurelia-release-notes-june-2018 (check new templating features part)
Would be great if @qraynaud or @ben-girardet could help with this PR 😬
Will publish a PR later today 👍🏻
@bigopon you can review the PR
I'm submitting a bug report
Please tell us about your environment:
Operating System: Linux (Docker image: node) | Windows 10 (with WSL)
Node Version: 13.10.0
NPM Version: 6.4.13
Webpack webpack 4.42.1
Browser: all
Language: ESNext
Current behavior:
Using the latest base project generated by
aurelia-cli
(with small twinkering in the webapp config, mainly to change a little how style files are loaded), when I'm building my app, it's working great if I'm in dev env (usingnpm run build:dev
).But if I build it in production environment (using
npm run build
) and serve it directly (http-server dist
), I get the following error in my console:Error: Unable to find module with ID: @aurelia-ux/form.html
(I noticed immediately that it seems to miss aform/
folder in the module name).I activated the debug log in production to get more details and here is what I see:
I don't find the debug helping there. We don't know why this module was required. Even more disturbing is the fact that
@aurelia-ux/form/ux-form.html
seems to have been loaded properly before the bug happens.Expected/desired behavior:
The app should work the same way whatever env we use for building it.
My app is currently open source, so if you want to check it out, here it is: https://heptapod.lsystems.fr/qraynaud/recipe-calculator