Skip to content
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

Register dependency serializers #205

Merged
merged 17 commits into from
May 6, 2022
Merged

Register dependency serializers #205

merged 17 commits into from
May 6, 2022

Conversation

elitastic
Copy link

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

Copy link
Member

@bigopon bigopon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one, thanks. Can we have someway to test the serialization behavior? Anything basic will do

@@ -21,8 +22,22 @@ class AureliaDependency extends IncludeDependency {
get [dependencyImports]() {
return webpack.Dependency.EXPORTS_OBJECT_REFERENCED as any;
}

serialize(context: any) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we know the type of this context? if we do, I'd prefer that we have it here instead of any

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ObjectSerializerContext . Unfortunately, this type is only listed but not exported in the webpack ts definition file if I see this correctly.

@elitastic
Copy link
Author

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 [email protected] requires a peer of webpack@>= 5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] 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
Copy link
Author

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
Copy link
Member

bigopon commented May 5, 2022

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

@elitastic
Copy link
Author

  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]
    }
  },
  1. npm start -> "my-component" is found and rendered
  2. wait 20-30 seconds until webpack has finishes building the cache -> should have files in node_modules/.cache/webpack
  3. npm start -> "my-component" is not rendered and cannot be found, see error in console

@bigopon
Copy link
Member

bigopon commented May 5, 2022

@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
Copy link
Author

Issue is fixed. preserveModuleName was not serialized on NormalModule.

@bigopon bigopon merged commit 6a08665 into aurelia:master May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Webpack 5 caching not working (No serializer registered for IncludeDependency/AureliaDependency)
2 participants