aurelia / webpack-plugin

A plugin for webpack that enables bundling Aurelia applications.
MIT License
90 stars 36 forks source link

Register dependency serializers #205

Closed elitastic closed 2 years ago

elitastic commented 2 years ago

Fixes #199, I added dependency serializers, this adds support for filesystem cache in webpack 5.

elitastic commented 2 years ago

I added a very simple test with filesystem cache enabled. Tests in pipeline are broken, is this caused by me?

"webpack" command seems to be missing in command line?

webpack --stats-error-details "--no-stats" 'webpack' is not recognized as an internal or external command,

npm install
npm WARN aurelia-webpack-plugin@5.0.3 requires a peer of webpack@>= 5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN aurelia-chart@0.3.4 requires a peer of chart.js@^3.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN app-basic@ No description
npm WARN app-basic@ No repository field.
npm WARN app-basic@ No license field.
added 1 package from 4 contributors and audited 17 packages in 2.415s
71 packages are looking for funding
  run `npm fund` for details
found 0 vulnerabilities
> app-basic@ build:ci D:\a\webpack-plugin\webpack-plugin\tests\app-basic
> npm run build -- --no-stats
> app-basic@ build D:\a\webpack-plugin\webpack-plugin\tests\app-basic
> webpack --stats-error-details "--no-stats"
'webpack' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! app-basic@ build: `webpack --stats-error-details "--no-stats"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the app-basic@ build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\npm\cache\_logs\2022-05-05T07_44_3[9](https://github.com/aurelia/webpack-plugin/runs/6302429069?check_suite_focus=true#step:5:9)_065Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! app-basic@ build:ci: `npm run build -- --no-stats`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the app-basic@ build:ci script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\npm\cache\_logs\2022-05-05T07_44_39_[10](https://github.com/aurelia/webpack-plugin/runs/6302429069?check_suite_focus=true#step:5:10)1Z-debug.log
Error: Process completed with exit code 1.
elitastic commented 2 years ago

There's a bug when working with view-model.bind. In the below pasted scenario, "my-component" cannot be found when building from cache:

Uncaught (in promise) Error: Unable to find module with ID: 274.html
    at WebpackLoader.<anonymous> (aurelia-loader-webpack.js:221:1)
    at step (aurelia-loader-webpack.js:68:1)
    at Object.next (aurelia-loader-webpack.js:49:1)
    at aurelia-loader-webpack.js:42:1
    at new Promise (<anonymous>)
    at __awaiter (aurelia-loader-webpack.js:38:1)
    at WebpackLoader._import (aurelia-loader-webpack.js:186:1)
    at WebpackLoader.<anonymous> (aurelia-loader-webpack.js:286:1)
    at step (aurelia-loader-webpack.js:68:1)
    at Object.next (aurelia-loader-webpack.js:49:1)

app.html

<template>
  <h1>Hello World</h1>
  <compose view-model.bind="viewModel"></compose>
</template>

app.ts

import { MyComponent } from "my-component";

export class App {
  viewModel = MyComponent;
}

my-component.html

<template>Test</template>

my-component.ts

export class MyComponent {
}
bigopon commented 2 years ago

@elitastic can you list the steps to reproduce the caching issue mentioned?

elitastic commented 2 years ago
  1. create empy aurelia 1 project au new
  2. paste / override app.ts/app.html/my-component.ts/my-component.html
  3. enable cache in webpack.config.js
    cache: {
    type: "filesystem",
    buildDependencies: {
      config: [__filename]
    }
    },
  4. npm start -> "my-component" is found and rendered
  5. wait 20-30 seconds until webpack has finishes building the cache -> should have files in node_modules/.cache/webpack
  6. npm start -> "my-component" is not rendered and cannot be found, see error in console
bigopon commented 2 years ago

@elitastic thanks, I'm able to see the errors, though I'm not sure what could be the cause. Totally unfamiliar with this class of issues. Are you able to help find a fix for it?

elitastic commented 2 years ago

Issue is fixed. preserveModuleName was not serialized on NormalModule.