From 3dc7bee1bfb55b56ea5ce4a89673ddaf9836b4dd Mon Sep 17 00:00:00 2001 From: "elias.stocker" Date: Thu, 5 May 2022 08:51:06 +0200 Subject: [PATCH 01/17] Register dependency serializers --- src/AureliaDependenciesPlugin.ts | 27 +++++++++++++++++++++------ src/ClassSerializer.ts | 19 +++++++++++++++++++ src/IncludeDependency.ts | 17 ++++++++++++++++- 3 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 src/ClassSerializer.ts diff --git a/src/AureliaDependenciesPlugin.ts b/src/AureliaDependenciesPlugin.ts index e562cd6..c2c2a36 100644 --- a/src/AureliaDependenciesPlugin.ts +++ b/src/AureliaDependenciesPlugin.ts @@ -1,4 +1,5 @@ import { IncludeDependency } from "./IncludeDependency"; +import { ClassSerializer } from "./ClassSerializer"; import * as estree from 'estree'; import * as webpack from 'webpack'; @@ -8,9 +9,9 @@ const BasicEvaluatedExpression: $BasicEvaluatedExpression = require("webpack/lib const TAP_NAME = "Aurelia:Dependencies"; class AureliaDependency extends IncludeDependency { - constructor(request: string, - public range: [number, number], - options?: DependencyOptions) { + constructor(public request: string, + public range: [number, number], + options?: DependencyOptions) { super(request, options); } @@ -21,8 +22,22 @@ class AureliaDependency extends IncludeDependency { get [dependencyImports]() { return webpack.Dependency.EXPORTS_OBJECT_REFERENCED as any; } + + serialize(context: any) { + const { write } = context; + write(this.range); + super.serialize(context); + } + + deserialize(context: any) { + const { read } = context; + this.range = read(); + super.deserialize(context); + } } +webpack.util.serialization.register(AureliaDependency, "AureliaDependency", null as any, new ClassSerializer(AureliaDependency)); + class Template { apply(dep: AureliaDependency, source: webpack.sources.ReplaceSource) { source.replace(dep.range[0], dep.range[1] - 1, "'" + dep.request.replace(/^async(?:\?[^!]*)?!/, "") + "'"); @@ -57,8 +72,8 @@ class ParserPlugin { // import('aurelia-pal').then(pal => pal.PLATFORM.moduleName(...)) // import('aurelia-pal').then({ PLATFORM } => PLATFORM.moduleName(...)) || expr.object.type === 'MemberExpression' - && expr.object.property.type === 'Identifier' - && expr.object.property.name === 'PLATFORM' + && expr.object.property.type === 'Identifier' + && expr.object.property.name === 'PLATFORM' ) ) { return new BasicEvaluatedExpression() @@ -100,7 +115,7 @@ class ParserPlugin { let value = parser.evaluateExpression(prop.value as estree.Literal)!; switch (prop.key.name) { case "chunk": - if (value.isString()) + if (value.isString()) options.chunk = value.string; break; case "exports": diff --git a/src/ClassSerializer.ts b/src/ClassSerializer.ts new file mode 100644 index 0000000..b211a85 --- /dev/null +++ b/src/ClassSerializer.ts @@ -0,0 +1,19 @@ +export class ClassSerializer { + constructor(private ctor: { new(...params: any[]): T }) { + } + + serialize(obj: T, context: any) { + obj.serialize(context); + } + + deserialize(context: any) { + const obj = new this.ctor(); + obj.deserialize(context); + return obj; + } +} + +interface ISerializable { + serialize(context: any): void; + deserialize(context: any): void +} \ No newline at end of file diff --git a/src/IncludeDependency.ts b/src/IncludeDependency.ts index 62226e7..1ab132c 100644 --- a/src/IncludeDependency.ts +++ b/src/IncludeDependency.ts @@ -2,6 +2,7 @@ import { dependencyImports } from "./PreserveExportsPlugin"; import { preserveModuleName } from "./PreserveModuleNamePlugin"; import * as webpack from 'webpack'; import { DependencyOptions, ReferencedExport } from "./interfaces"; +import { ClassSerializer } from "./ClassSerializer"; export class IncludeDependency extends webpack.dependencies.ModuleDependency { protected options?: DependencyOptions; @@ -30,7 +31,21 @@ export class IncludeDependency extends webpack.dependencies.ModuleDependency { get [dependencyImports]() { return this.options?.exports; } + + serialize(context: any) { + const { write } = context; + write(this.options); + super.serialize(context); + } + + deserialize(context: any) { + const { read } = context; + this.options = read(); + super.deserialize(context); + } }; +webpack.util.serialization.register(IncludeDependency, "IncludeDependency", null as any, new ClassSerializer(IncludeDependency)); + export type NullDependencyTemplate = typeof webpack.dependencies.NullDependency.Template; -export const Template: NullDependencyTemplate = webpack.dependencies.NullDependency.Template; +export const Template: NullDependencyTemplate = webpack.dependencies.NullDependency.Template; \ No newline at end of file From a1ce4196568aae85fbe7604b8f2a9261f899f98f Mon Sep 17 00:00:00 2001 From: "elias.stocker" Date: Thu, 5 May 2022 08:55:20 +0200 Subject: [PATCH 02/17] revert formatting changes --- src/AureliaDependenciesPlugin.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/AureliaDependenciesPlugin.ts b/src/AureliaDependenciesPlugin.ts index c2c2a36..7b41e13 100644 --- a/src/AureliaDependenciesPlugin.ts +++ b/src/AureliaDependenciesPlugin.ts @@ -10,8 +10,8 @@ const TAP_NAME = "Aurelia:Dependencies"; class AureliaDependency extends IncludeDependency { constructor(public request: string, - public range: [number, number], - options?: DependencyOptions) { + public range: [number, number], + options?: DependencyOptions) { super(request, options); } @@ -72,8 +72,8 @@ class ParserPlugin { // import('aurelia-pal').then(pal => pal.PLATFORM.moduleName(...)) // import('aurelia-pal').then({ PLATFORM } => PLATFORM.moduleName(...)) || expr.object.type === 'MemberExpression' - && expr.object.property.type === 'Identifier' - && expr.object.property.name === 'PLATFORM' + && expr.object.property.type === 'Identifier' + && expr.object.property.name === 'PLATFORM' ) ) { return new BasicEvaluatedExpression() From 411272a9fa19f72e80e58b11de57b26dd169083c Mon Sep 17 00:00:00 2001 From: "elias.stocker" Date: Thu, 5 May 2022 09:16:01 +0200 Subject: [PATCH 03/17] refresh dist files --- dist/AureliaDependenciesPlugin.js | 13 +++++++++++++ dist/ClassSerializer.js | 17 +++++++++++++++++ dist/IncludeDependency.js | 12 ++++++++++++ dist/types/ClassSerializer.d.ts | 13 +++++++++++++ dist/types/IncludeDependency.d.ts | 2 ++ 5 files changed, 57 insertions(+) create mode 100644 dist/ClassSerializer.js create mode 100644 dist/types/ClassSerializer.d.ts diff --git a/dist/AureliaDependenciesPlugin.js b/dist/AureliaDependenciesPlugin.js index 584d726..8cc89ab 100644 --- a/dist/AureliaDependenciesPlugin.js +++ b/dist/AureliaDependenciesPlugin.js @@ -2,6 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.AureliaDependenciesPlugin = void 0; const IncludeDependency_1 = require("./IncludeDependency"); +const ClassSerializer_1 = require("./ClassSerializer"); const webpack = require("webpack"); const PreserveExportsPlugin_1 = require("./PreserveExportsPlugin"); const BasicEvaluatedExpression = require("webpack/lib/javascript/BasicEvaluatedExpression"); @@ -9,6 +10,7 @@ const TAP_NAME = "Aurelia:Dependencies"; class AureliaDependency extends IncludeDependency_1.IncludeDependency { constructor(request, range, options) { super(request, options); + this.request = request; this.range = range; } get type() { @@ -17,7 +19,18 @@ class AureliaDependency extends IncludeDependency_1.IncludeDependency { get [PreserveExportsPlugin_1.dependencyImports]() { return webpack.Dependency.EXPORTS_OBJECT_REFERENCED; } + serialize(context) { + const { write } = context; + write(this.range); + super.serialize(context); + } + deserialize(context) { + const { read } = context; + this.range = read(); + super.deserialize(context); + } } +webpack.util.serialization.register(AureliaDependency, "AureliaDependency", null, new ClassSerializer_1.ClassSerializer(AureliaDependency)); class Template { apply(dep, source) { source.replace(dep.range[0], dep.range[1] - 1, "'" + dep.request.replace(/^async(?:\?[^!]*)?!/, "") + "'"); diff --git a/dist/ClassSerializer.js b/dist/ClassSerializer.js new file mode 100644 index 0000000..38432b1 --- /dev/null +++ b/dist/ClassSerializer.js @@ -0,0 +1,17 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ClassSerializer = void 0; +class ClassSerializer { + constructor(ctor) { + this.ctor = ctor; + } + serialize(obj, context) { + obj.serialize(context); + } + deserialize(context) { + const obj = new this.ctor(); + obj.deserialize(context); + return obj; + } +} +exports.ClassSerializer = ClassSerializer; diff --git a/dist/IncludeDependency.js b/dist/IncludeDependency.js index 9cb9cc4..8bf42c2 100644 --- a/dist/IncludeDependency.js +++ b/dist/IncludeDependency.js @@ -4,6 +4,7 @@ exports.Template = exports.IncludeDependency = void 0; const PreserveExportsPlugin_1 = require("./PreserveExportsPlugin"); const PreserveModuleNamePlugin_1 = require("./PreserveModuleNamePlugin"); const webpack = require("webpack"); +const ClassSerializer_1 = require("./ClassSerializer"); class IncludeDependency extends webpack.dependencies.ModuleDependency { constructor(request, options) { let chunk = options && options.chunk; @@ -27,7 +28,18 @@ class IncludeDependency extends webpack.dependencies.ModuleDependency { var _a; return (_a = this.options) === null || _a === void 0 ? void 0 : _a.exports; } + serialize(context) { + const { write } = context; + write(this.options); + super.serialize(context); + } + deserialize(context) { + const { read } = context; + this.options = read(); + super.deserialize(context); + } } exports.IncludeDependency = IncludeDependency; ; +webpack.util.serialization.register(IncludeDependency, "IncludeDependency", null, new ClassSerializer_1.ClassSerializer(IncludeDependency)); exports.Template = webpack.dependencies.NullDependency.Template; diff --git a/dist/types/ClassSerializer.d.ts b/dist/types/ClassSerializer.d.ts new file mode 100644 index 0000000..344d44a --- /dev/null +++ b/dist/types/ClassSerializer.d.ts @@ -0,0 +1,13 @@ +export declare class ClassSerializer { + private ctor; + constructor(ctor: { + new (...params: any[]): T; + }); + serialize(obj: T, context: any): void; + deserialize(context: any): T; +} +interface ISerializable { + serialize(context: any): void; + deserialize(context: any): void; +} +export {}; diff --git a/dist/types/IncludeDependency.d.ts b/dist/types/IncludeDependency.d.ts index eb26592..de1b58e 100644 --- a/dist/types/IncludeDependency.d.ts +++ b/dist/types/IncludeDependency.d.ts @@ -9,6 +9,8 @@ export declare class IncludeDependency extends webpack.dependencies.ModuleDepend getReferencedExports(moduleGraph: webpack.ModuleGraph): (string[] | ReferencedExport)[]; get [preserveModuleName](): boolean; get [dependencyImports](): string[] | undefined; + serialize(context: any): void; + deserialize(context: any): void; } export declare type NullDependencyTemplate = typeof webpack.dependencies.NullDependency.Template; export declare const Template: NullDependencyTemplate; From d2ab72f4a92fab59d88eccc70c1541c4808d0328 Mon Sep 17 00:00:00 2001 From: "elias.stocker" Date: Thu, 5 May 2022 09:42:02 +0200 Subject: [PATCH 04/17] app-filesystem-cache test added --- tests/app-filesystem-cache/index.ejs | 12 ++++ tests/app-filesystem-cache/package.json | 15 +++++ tests/app-filesystem-cache/src/app.html | 3 + tests/app-filesystem-cache/src/app.ts | 3 + tests/app-filesystem-cache/src/main.ts | 9 +++ tests/app-filesystem-cache/tsconfig.json | 13 +++++ tests/app-filesystem-cache/webpack.config.js | 58 ++++++++++++++++++++ 7 files changed, 113 insertions(+) create mode 100644 tests/app-filesystem-cache/index.ejs create mode 100644 tests/app-filesystem-cache/package.json create mode 100644 tests/app-filesystem-cache/src/app.html create mode 100644 tests/app-filesystem-cache/src/app.ts create mode 100644 tests/app-filesystem-cache/src/main.ts create mode 100644 tests/app-filesystem-cache/tsconfig.json create mode 100644 tests/app-filesystem-cache/webpack.config.js diff --git a/tests/app-filesystem-cache/index.ejs b/tests/app-filesystem-cache/index.ejs new file mode 100644 index 0000000..29f5d98 --- /dev/null +++ b/tests/app-filesystem-cache/index.ejs @@ -0,0 +1,12 @@ + + + + + + + Aurelia app + + +
+ + diff --git a/tests/app-filesystem-cache/package.json b/tests/app-filesystem-cache/package.json new file mode 100644 index 0000000..4b47771 --- /dev/null +++ b/tests/app-filesystem-cache/package.json @@ -0,0 +1,15 @@ +{ + "name": "app-basic", + "scripts": { + "dev": "webpack serve", + "build": "webpack --stats-error-details", + "build:prod": "webpack --mode=production", + "prebuild:ci": "npm install", + "build:ci": "npm run build -- --no-stats", + "install:plugin": "npm install ../../", + "rimraf": "rimraf dist/**/*.js" + }, + "dependencies": { + "aurelia-webpack-plugin": "file:../.." + } +} diff --git a/tests/app-filesystem-cache/src/app.html b/tests/app-filesystem-cache/src/app.html new file mode 100644 index 0000000..06ac72d --- /dev/null +++ b/tests/app-filesystem-cache/src/app.html @@ -0,0 +1,3 @@ + diff --git a/tests/app-filesystem-cache/src/app.ts b/tests/app-filesystem-cache/src/app.ts new file mode 100644 index 0000000..a362efa --- /dev/null +++ b/tests/app-filesystem-cache/src/app.ts @@ -0,0 +1,3 @@ +export class App { + appDate: Date = new Date(); +} \ No newline at end of file diff --git a/tests/app-filesystem-cache/src/main.ts b/tests/app-filesystem-cache/src/main.ts new file mode 100644 index 0000000..da235a5 --- /dev/null +++ b/tests/app-filesystem-cache/src/main.ts @@ -0,0 +1,9 @@ +import { Aurelia, PLATFORM } from 'aurelia-framework'; + +export async function configure(aurelia: Aurelia) { + aurelia.use + .basicConfiguration(); + + await aurelia.start(); + await aurelia.setRoot(PLATFORM.moduleName('app')); +} diff --git a/tests/app-filesystem-cache/tsconfig.json b/tests/app-filesystem-cache/tsconfig.json new file mode 100644 index 0000000..7991e47 --- /dev/null +++ b/tests/app-filesystem-cache/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "esnext", + "baseUrl": "src", + "module": "es2015", + "moduleResolution": "node", + "experimentalDecorators": true, + "lib": [ + "dom", + "es2017" + ] + } +} diff --git a/tests/app-filesystem-cache/webpack.config.js b/tests/app-filesystem-cache/webpack.config.js new file mode 100644 index 0000000..900aa45 --- /dev/null +++ b/tests/app-filesystem-cache/webpack.config.js @@ -0,0 +1,58 @@ +const { AureliaPlugin } = require('aurelia-webpack-plugin'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const CopyWebpackPlugin = require('copy-webpack-plugin'); +const path = require('path'); + +Error.stackTraceLimit = Infinity; + +/** + * @returns {import('webpack').Configuration} + */ +module.exports = (env = {}) => { + return { + mode: 'development', + target: 'web', + cache: { + type: 'filesystem' + }, + resolve: { + extensions: [".ts", ".js"], + modules: [ + // this is only needed inside for the tests in this repo + // in normal application, can just use "src" instead of an absolute path to it + path.resolve(__dirname, "src"), + 'node_modules' + ] + }, + entry: { + // application entry file is app + app: ["aurelia-bootstrapper"], + }, + output: { + // If production, add a hash to burst cache + filename: '[name].js' + }, + module: { + rules: [ + { + test: /\.ts$/, + loader: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /\.html$/, + loader: 'html-loader' + } + ] + }, + plugins: [ + new AureliaPlugin({ + aureliaConfig: ['basic'], + }), + // Standard plugin to build index.html + new HtmlWebpackPlugin({ + template: 'index.ejs' + }) + ] + }; +}; From 23a47fe5eb8f3c18ecff8f216243f4859e87e621 Mon Sep 17 00:00:00 2001 From: bigopon Date: Thu, 5 May 2022 22:11:57 +1000 Subject: [PATCH 05/17] refactor: add typings to serialization context --- src/AureliaDependenciesPlugin.ts | 2 +- src/ClassSerializer.ts | 10 ++++++---- src/IncludeDependency.ts | 2 +- src/webpack.d.ts | 11 +++++++++++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/AureliaDependenciesPlugin.ts b/src/AureliaDependenciesPlugin.ts index 7b41e13..3d50772 100644 --- a/src/AureliaDependenciesPlugin.ts +++ b/src/AureliaDependenciesPlugin.ts @@ -36,7 +36,7 @@ class AureliaDependency extends IncludeDependency { } } -webpack.util.serialization.register(AureliaDependency, "AureliaDependency", null as any, new ClassSerializer(AureliaDependency)); +webpack.util.serialization.register(AureliaDependency, "AureliaDependency", "AureliaDependency", new ClassSerializer(AureliaDependency)); class Template { apply(dep: AureliaDependency, source: webpack.sources.ReplaceSource) { diff --git a/src/ClassSerializer.ts b/src/ClassSerializer.ts index b211a85..1fad057 100644 --- a/src/ClassSerializer.ts +++ b/src/ClassSerializer.ts @@ -1,12 +1,14 @@ +import { ObjectDeserializerContext, ObjectSerializerContext } from "./webpack"; + export class ClassSerializer { constructor(private ctor: { new(...params: any[]): T }) { } - serialize(obj: T, context: any) { + serialize(obj: T, context: ObjectSerializerContext) { obj.serialize(context); } - deserialize(context: any) { + deserialize(context: ObjectDeserializerContext) { const obj = new this.ctor(); obj.deserialize(context); return obj; @@ -14,6 +16,6 @@ export class ClassSerializer { } interface ISerializable { - serialize(context: any): void; - deserialize(context: any): void + serialize(context: ObjectSerializerContext): void; + deserialize(context: ObjectDeserializerContext): void } \ No newline at end of file diff --git a/src/IncludeDependency.ts b/src/IncludeDependency.ts index 1ab132c..06a3dd3 100644 --- a/src/IncludeDependency.ts +++ b/src/IncludeDependency.ts @@ -45,7 +45,7 @@ export class IncludeDependency extends webpack.dependencies.ModuleDependency { } }; -webpack.util.serialization.register(IncludeDependency, "IncludeDependency", null as any, new ClassSerializer(IncludeDependency)); +webpack.util.serialization.register(IncludeDependency, "IncludeDependency", "IncludeDependency", new ClassSerializer(IncludeDependency)); export type NullDependencyTemplate = typeof webpack.dependencies.NullDependency.Template; export const Template: NullDependencyTemplate = webpack.dependencies.NullDependency.Template; \ No newline at end of file diff --git a/src/webpack.d.ts b/src/webpack.d.ts index f862cdc..16e76b1 100644 --- a/src/webpack.d.ts +++ b/src/webpack.d.ts @@ -4,3 +4,14 @@ declare module "html-loader/lib/attributesParser" { export = parse; } + +export interface ObjectDeserializerContext { + read: () => any; +} +export interface ObjectSerializer { + serialize: (arg0: any, arg1: ObjectSerializerContext) => void; + deserialize: (arg0: ObjectDeserializerContext) => any; +} +export interface ObjectSerializerContext { + write: (arg0?: any) => void; +} From f6b6b4bc0920717cb3fb4a8c2df4fb7ecb9b775c Mon Sep 17 00:00:00 2001 From: bigopon Date: Thu, 5 May 2022 22:38:11 +1000 Subject: [PATCH 06/17] fix(pnpm): ensure peer deps --- package-lock.json | 67 +++++++++++++++++++++++++++++++++++++++++------ package.json | 4 ++- 2 files changed, 62 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 84a4869..3c85a9e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -67,9 +67,23 @@ "webpack-dev-server": "^4.4.0" }, "peerDependencies": { + "chart.js": "^3.7.1", + "redux": "^4.2.0", "webpack": ">= 5.0.0" } }, + "node_modules/@babel/runtime": { + "version": "7.17.9", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.17.9.tgz", + "integrity": "sha512-lSiBBvodq29uShpWGNbgFdKYNiFDo5/HIYsaCEY9ff4sb10x9jizo2+pRrSyF4jKZCXqgzuqBOQKbUm90gQwJg==", + "peer": true, + "dependencies": { + "regenerator-runtime": "^0.13.4" + }, + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@discoveryjs/json-ext": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.2.tgz", @@ -1134,10 +1148,9 @@ } }, "node_modules/chart.js": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.2.1.tgz", - "integrity": "sha512-XsNDf3854RGZkLCt+5vWAXGAtUdKP2nhfikLGZqud6G4CvRE2ts64TIxTTfspOin2kEZvPgomE29E6oU02dYjQ==", - "dev": true, + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.7.1.tgz", + "integrity": "sha512-8knRegQLFnPQAheZV8MjxIXc5gQEfDFD897BJgv/klO/vtIyFFmgMXrNfgrXpbTr/XbTturxRgxIXx/Y+ASJBA==", "peer": true }, "node_modules/check-error": { @@ -4553,6 +4566,21 @@ "node": ">= 0.10" } }, + "node_modules/redux": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/redux/-/redux-4.2.0.tgz", + "integrity": "sha512-oSBmcKKIuIR4ME29/AeNUnl5L+hvBq7OaJWzaptTQJAntaPvxIJqfnjbaEiCzzaIz+XmVILfqAM3Ob0aXLPfjA==", + "peer": true, + "dependencies": { + "@babel/runtime": "^7.9.2" + } + }, + "node_modules/regenerator-runtime": { + "version": "0.13.9", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", + "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==", + "peer": true + }, "node_modules/regexp.prototype.flags": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.3.1.tgz", @@ -5836,6 +5864,15 @@ } }, "dependencies": { + "@babel/runtime": { + "version": "7.17.9", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.17.9.tgz", + "integrity": "sha512-lSiBBvodq29uShpWGNbgFdKYNiFDo5/HIYsaCEY9ff4sb10x9jizo2+pRrSyF4jKZCXqgzuqBOQKbUm90gQwJg==", + "peer": true, + "requires": { + "regenerator-runtime": "^0.13.4" + } + }, "@discoveryjs/json-ext": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.2.tgz", @@ -6784,10 +6821,9 @@ } }, "chart.js": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.2.1.tgz", - "integrity": "sha512-XsNDf3854RGZkLCt+5vWAXGAtUdKP2nhfikLGZqud6G4CvRE2ts64TIxTTfspOin2kEZvPgomE29E6oU02dYjQ==", - "dev": true, + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.7.1.tgz", + "integrity": "sha512-8knRegQLFnPQAheZV8MjxIXc5gQEfDFD897BJgv/klO/vtIyFFmgMXrNfgrXpbTr/XbTturxRgxIXx/Y+ASJBA==", "peer": true }, "check-error": { @@ -9384,6 +9420,21 @@ "resolve": "^1.9.0" } }, + "redux": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/redux/-/redux-4.2.0.tgz", + "integrity": "sha512-oSBmcKKIuIR4ME29/AeNUnl5L+hvBq7OaJWzaptTQJAntaPvxIJqfnjbaEiCzzaIz+XmVILfqAM3Ob0aXLPfjA==", + "peer": true, + "requires": { + "@babel/runtime": "^7.9.2" + } + }, + "regenerator-runtime": { + "version": "0.13.9", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", + "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==", + "peer": true + }, "regexp.prototype.flags": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.3.1.tgz", diff --git a/package.json b/package.json index 2369531..33c1a02 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,9 @@ "parse5": "^5.1.1" }, "peerDependencies": { - "webpack": ">= 5.0.0" + "webpack": ">= 5.0.0", + "chart.js": "^3.7.1", + "redux": "^4.2.0" }, "devDependencies": { "@types/chai": "^4.2.22", From a309764930de93e5a6117916c3b22a5c0212d6ac Mon Sep 17 00:00:00 2001 From: bigopon Date: Thu, 5 May 2022 22:59:13 +1000 Subject: [PATCH 07/17] fix(ci): use link-parent-bin --- .github/workflows/action.yml | 4 + package-lock.json | 236 +++++++++++++++++++++++++++++++++++ package.json | 6 +- 3 files changed, 244 insertions(+), 2 deletions(-) diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index d8eb552..3994099 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -46,6 +46,10 @@ jobs: npm run build:ci ../../node_modules/.bin/karma.cmd start --singleRun + - name: Test caching + working-directory: ./tests/app-filesystem-cache + run: npm run build:ci + # - name: Test build app using 3rd party lib # working-directory: ./tests/app-plugin-3rd-party # run: npm run build:ci diff --git a/package-lock.json b/package-lock.json index 3c85a9e..42d9c38 100644 --- a/package-lock.json +++ b/package-lock.json @@ -56,6 +56,7 @@ "karma-mocha": "^2.0.1", "karma-sourcemap-loader": "^0.3.8", "karma-webpack": "^5.0.0", + "link-parent-bin": "^2.0.0", "mini-css-extract-plugin": "^2.4.4", "mocha": "^9.1.3", "rimraf": "^3.0.2", @@ -527,6 +528,12 @@ "node": ">=8" } }, + "node_modules/any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8=", + "dev": true + }, "node_modules/anymatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", @@ -1183,6 +1190,15 @@ "fsevents": "~2.3.2" } }, + "node_modules/chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "node_modules/chrome-trace-event": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz", @@ -1227,6 +1243,18 @@ "node": ">=6" } }, + "node_modules/cmd-shim": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cmd-shim/-/cmd-shim-4.1.0.tgz", + "integrity": "sha512-lb9L7EM4I/ZRVuljLPEtUJOP+xiQVknZ4ZMpMgEp4JzNldPb27HU03hi6K1/6CoIuit/Zm/LQXySErFeXxDprw==", + "dev": true, + "dependencies": { + "mkdirp-infer-owner": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -2781,6 +2809,12 @@ "node": ">=8" } }, + "node_modules/infer-owner": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/infer-owner/-/infer-owner-1.0.4.tgz", + "integrity": "sha512-IClj+Xz94+d7irH5qRyfJonOdfTzuDaifE6ZPWfx0N0+/ATZCbuTPq2prFl526urkQd90WyUKIh1DfBQ2hMz9A==", + "dev": true + }, "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -3363,6 +3397,47 @@ "node": ">=0.10.0" } }, + "node_modules/link-parent-bin": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/link-parent-bin/-/link-parent-bin-2.0.0.tgz", + "integrity": "sha512-Z5k5dJ7R5mmZpVSnyt3q21wI6goJuL7eYdKgdoZLWtSepY7rvwLGa03W+NqHLQl5ruTgoqn8XD/HYBQuyHHkRg==", + "dev": true, + "dependencies": { + "cmd-shim": "^4.0.2", + "commander": "^6.1.0", + "log4js": "^6.3.0", + "minimatch": "^3.0.4", + "mkdirp": "^1.0.4", + "mz": "^2.7.0" + }, + "bin": { + "link-parent-bin": "bin/link-parent-bin" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/link-parent-bin/node_modules/commander": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz", + "integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, + "node_modules/link-parent-bin/node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/loader-runner": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.2.0.tgz", @@ -3607,6 +3682,32 @@ "mkdirp": "bin/cmd.js" } }, + "node_modules/mkdirp-infer-owner": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mkdirp-infer-owner/-/mkdirp-infer-owner-2.0.0.tgz", + "integrity": "sha512-sdqtiFt3lkOaYvTXSRIUjkIdPTcxgv5+fgqYE/5qgwdw12cOrAuzzgzvVExIkH/ul1oeHN3bCLOWSG3XOqbKKw==", + "dev": true, + "dependencies": { + "chownr": "^2.0.0", + "infer-owner": "^1.0.4", + "mkdirp": "^1.0.3" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mkdirp-infer-owner/node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/mocha": { "version": "9.1.3", "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.1.3.tgz", @@ -3844,6 +3945,17 @@ "integrity": "sha1-iZ8R2WhuXgXLkbNdXw5jt3PPyQE=", "dev": true }, + "node_modules/mz": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", + "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", + "dev": true, + "dependencies": { + "any-promise": "^1.0.0", + "object-assign": "^4.0.1", + "thenify-all": "^1.0.0" + } + }, "node_modules/nanoid": { "version": "3.1.25", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.25.tgz", @@ -5254,6 +5366,27 @@ "node": ">= 8" } }, + "node_modules/thenify": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", + "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", + "dev": true, + "dependencies": { + "any-promise": "^1.0.0" + } + }, + "node_modules/thenify-all": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", + "integrity": "sha1-GhkY1ALY/D+Y+/I02wvMjMEOlyY=", + "dev": true, + "dependencies": { + "thenify": ">= 3.1.0 < 4" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/thunky": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz", @@ -6265,6 +6398,12 @@ "color-convert": "^2.0.1" } }, + "any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8=", + "dev": true + }, "anymatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", @@ -6848,6 +6987,12 @@ "readdirp": "~3.6.0" } }, + "chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", + "dev": true + }, "chrome-trace-event": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz", @@ -6880,6 +7025,15 @@ "shallow-clone": "^3.0.0" } }, + "cmd-shim": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cmd-shim/-/cmd-shim-4.1.0.tgz", + "integrity": "sha512-lb9L7EM4I/ZRVuljLPEtUJOP+xiQVknZ4ZMpMgEp4JzNldPb27HU03hi6K1/6CoIuit/Zm/LQXySErFeXxDprw==", + "dev": true, + "requires": { + "mkdirp-infer-owner": "^2.0.0" + } + }, "color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -8097,6 +8251,12 @@ "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", "dev": true }, + "infer-owner": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/infer-owner/-/infer-owner-1.0.4.tgz", + "integrity": "sha512-IClj+Xz94+d7irH5qRyfJonOdfTzuDaifE6ZPWfx0N0+/ATZCbuTPq2prFl526urkQd90WyUKIh1DfBQ2hMz9A==", + "dev": true + }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -8534,6 +8694,34 @@ "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", "dev": true }, + "link-parent-bin": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/link-parent-bin/-/link-parent-bin-2.0.0.tgz", + "integrity": "sha512-Z5k5dJ7R5mmZpVSnyt3q21wI6goJuL7eYdKgdoZLWtSepY7rvwLGa03W+NqHLQl5ruTgoqn8XD/HYBQuyHHkRg==", + "dev": true, + "requires": { + "cmd-shim": "^4.0.2", + "commander": "^6.1.0", + "log4js": "^6.3.0", + "minimatch": "^3.0.4", + "mkdirp": "^1.0.4", + "mz": "^2.7.0" + }, + "dependencies": { + "commander": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz", + "integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==", + "dev": true + }, + "mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true + } + } + }, "loader-runner": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.2.0.tgz", @@ -8711,6 +8899,25 @@ "minimist": "^1.2.5" } }, + "mkdirp-infer-owner": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mkdirp-infer-owner/-/mkdirp-infer-owner-2.0.0.tgz", + "integrity": "sha512-sdqtiFt3lkOaYvTXSRIUjkIdPTcxgv5+fgqYE/5qgwdw12cOrAuzzgzvVExIkH/ul1oeHN3bCLOWSG3XOqbKKw==", + "dev": true, + "requires": { + "chownr": "^2.0.0", + "infer-owner": "^1.0.4", + "mkdirp": "^1.0.3" + }, + "dependencies": { + "mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true + } + } + }, "mocha": { "version": "9.1.3", "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.1.3.tgz", @@ -8888,6 +9095,17 @@ "integrity": "sha1-iZ8R2WhuXgXLkbNdXw5jt3PPyQE=", "dev": true }, + "mz": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", + "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", + "dev": true, + "requires": { + "any-promise": "^1.0.0", + "object-assign": "^4.0.1", + "thenify-all": "^1.0.0" + } + }, "nanoid": { "version": "3.1.25", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.25.tgz", @@ -9960,6 +10178,24 @@ "terser": "^5.7.2" } }, + "thenify": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", + "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", + "dev": true, + "requires": { + "any-promise": "^1.0.0" + } + }, + "thenify-all": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", + "integrity": "sha1-GhkY1ALY/D+Y+/I02wvMjMEOlyY=", + "dev": true, + "requires": { + "thenify": ">= 3.1.0 < 4" + } + }, "thunky": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz", diff --git a/package.json b/package.json index 33c1a02..9c0be18 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "runtime" ], "scripts": { + "postinstall": "link-parent-bin -c tests", "build": "tsc", "build:watch": "tsc --watch", "test": "cd tests/app-basic && npm run build:ci", @@ -48,9 +49,9 @@ "parse5": "^5.1.1" }, "peerDependencies": { - "webpack": ">= 5.0.0", "chart.js": "^3.7.1", - "redux": "^4.2.0" + "redux": "^4.2.0", + "webpack": ">= 5.0.0" }, "devDependencies": { "@types/chai": "^4.2.22", @@ -94,6 +95,7 @@ "karma-mocha": "^2.0.1", "karma-sourcemap-loader": "^0.3.8", "karma-webpack": "^5.0.0", + "link-parent-bin": "^2.0.0", "mini-css-extract-plugin": "^2.4.4", "mocha": "^9.1.3", "rimraf": "^3.0.2", From 9b0270a4a843c5bddfc5e3e4b60924e8dbc262f1 Mon Sep 17 00:00:00 2001 From: bigopon Date: Thu, 5 May 2022 23:07:03 +1000 Subject: [PATCH 08/17] fix(ci): pnpm peer deps --- package-lock.json | 21 +++++++++++---------- package.json | 4 ++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index 42d9c38..54e21b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,6 +7,7 @@ "": { "name": "aurelia-webpack-plugin", "version": "5.0.3", + "hasInstallScript": true, "license": "MIT", "dependencies": { "aurelia-loader-webpack": "^2.2.4", @@ -47,6 +48,7 @@ "aurelia-templating-router": "^1.4.0", "aurelia-testing": "^1.0.0", "chai": "^4.3.4", + "chart.js": "^3.7.1", "copy-webpack-plugin": "^9.0.1", "css-loader": "^6.5.1", "html-loader": "^3.0.1", @@ -59,6 +61,7 @@ "link-parent-bin": "^2.0.0", "mini-css-extract-plugin": "^2.4.4", "mocha": "^9.1.3", + "redux": "^4.2.0", "rimraf": "^3.0.2", "ts-loader": "^9.2.6", "tslib": "^2.3.1", @@ -68,8 +71,6 @@ "webpack-dev-server": "^4.4.0" }, "peerDependencies": { - "chart.js": "^3.7.1", - "redux": "^4.2.0", "webpack": ">= 5.0.0" } }, @@ -77,7 +78,7 @@ "version": "7.17.9", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.17.9.tgz", "integrity": "sha512-lSiBBvodq29uShpWGNbgFdKYNiFDo5/HIYsaCEY9ff4sb10x9jizo2+pRrSyF4jKZCXqgzuqBOQKbUm90gQwJg==", - "peer": true, + "dev": true, "dependencies": { "regenerator-runtime": "^0.13.4" }, @@ -1158,7 +1159,7 @@ "version": "3.7.1", "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.7.1.tgz", "integrity": "sha512-8knRegQLFnPQAheZV8MjxIXc5gQEfDFD897BJgv/klO/vtIyFFmgMXrNfgrXpbTr/XbTturxRgxIXx/Y+ASJBA==", - "peer": true + "dev": true }, "node_modules/check-error": { "version": "1.0.2", @@ -4682,7 +4683,7 @@ "version": "4.2.0", "resolved": "https://registry.npmjs.org/redux/-/redux-4.2.0.tgz", "integrity": "sha512-oSBmcKKIuIR4ME29/AeNUnl5L+hvBq7OaJWzaptTQJAntaPvxIJqfnjbaEiCzzaIz+XmVILfqAM3Ob0aXLPfjA==", - "peer": true, + "dev": true, "dependencies": { "@babel/runtime": "^7.9.2" } @@ -4691,7 +4692,7 @@ "version": "0.13.9", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==", - "peer": true + "dev": true }, "node_modules/regexp.prototype.flags": { "version": "1.3.1", @@ -6001,7 +6002,7 @@ "version": "7.17.9", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.17.9.tgz", "integrity": "sha512-lSiBBvodq29uShpWGNbgFdKYNiFDo5/HIYsaCEY9ff4sb10x9jizo2+pRrSyF4jKZCXqgzuqBOQKbUm90gQwJg==", - "peer": true, + "dev": true, "requires": { "regenerator-runtime": "^0.13.4" } @@ -6963,7 +6964,7 @@ "version": "3.7.1", "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.7.1.tgz", "integrity": "sha512-8knRegQLFnPQAheZV8MjxIXc5gQEfDFD897BJgv/klO/vtIyFFmgMXrNfgrXpbTr/XbTturxRgxIXx/Y+ASJBA==", - "peer": true + "dev": true }, "check-error": { "version": "1.0.2", @@ -9642,7 +9643,7 @@ "version": "4.2.0", "resolved": "https://registry.npmjs.org/redux/-/redux-4.2.0.tgz", "integrity": "sha512-oSBmcKKIuIR4ME29/AeNUnl5L+hvBq7OaJWzaptTQJAntaPvxIJqfnjbaEiCzzaIz+XmVILfqAM3Ob0aXLPfjA==", - "peer": true, + "dev": true, "requires": { "@babel/runtime": "^7.9.2" } @@ -9651,7 +9652,7 @@ "version": "0.13.9", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==", - "peer": true + "dev": true }, "regexp.prototype.flags": { "version": "1.3.1", diff --git a/package.json b/package.json index 9c0be18..70af8bd 100644 --- a/package.json +++ b/package.json @@ -49,8 +49,6 @@ "parse5": "^5.1.1" }, "peerDependencies": { - "chart.js": "^3.7.1", - "redux": "^4.2.0", "webpack": ">= 5.0.0" }, "devDependencies": { @@ -86,6 +84,8 @@ "aurelia-templating-router": "^1.4.0", "aurelia-testing": "^1.0.0", "chai": "^4.3.4", + "chart.js": "^3.7.1", + "redux": "^4.2.0", "copy-webpack-plugin": "^9.0.1", "css-loader": "^6.5.1", "html-loader": "^3.0.1", From d6b07af8824a2ca72821b7c2700e2afc26d95463 Mon Sep 17 00:00:00 2001 From: bigopon Date: Thu, 5 May 2022 23:18:18 +1000 Subject: [PATCH 09/17] fix(ci): use hoist for pnpm, move link parent bin to config --- .github/workflows/action.yml | 6 ++++-- package.json | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index 3994099..54649ee 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -16,7 +16,9 @@ jobs: with: node-version: ${{ matrix.node-version }} - name: Install dependencies - run: npm ci + run: | + npm ci + npx link-parent-bin - name: Test build basic app working-directory: ./tests/app-basic @@ -80,7 +82,7 @@ jobs: - name: Prepare test PNPM run: | npm i -g pnpm - pnpm install + pnpm install --shamefully-hoist - name: Test build basic app with PNPM working-directory: ./tests/app-pnpm diff --git a/package.json b/package.json index 70af8bd..ac9b856 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,6 @@ "runtime" ], "scripts": { - "postinstall": "link-parent-bin -c tests", "build": "tsc", "build:watch": "tsc --watch", "test": "cd tests/app-basic && npm run build:ci", From c4c5d6f35b7ec9b277c701c20ff1fb141b0e1680 Mon Sep 17 00:00:00 2001 From: bigopon Date: Thu, 5 May 2022 23:21:19 +1000 Subject: [PATCH 10/17] fix(ci): tweak link parent bin script --- .github/workflows/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index 54649ee..be9beef 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -18,7 +18,7 @@ jobs: - name: Install dependencies run: | npm ci - npx link-parent-bin + npx link-parent-bin -c tests - name: Test build basic app working-directory: ./tests/app-basic From 5525c44c7b4b64812e053d705a9a68887cbcd7e3 Mon Sep 17 00:00:00 2001 From: bigopon Date: Thu, 5 May 2022 23:29:00 +1000 Subject: [PATCH 11/17] fix(tests): tweak install script app test --- tests/app-pnpm/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/app-pnpm/package.json b/tests/app-pnpm/package.json index 99c857e..623ace6 100644 --- a/tests/app-pnpm/package.json +++ b/tests/app-pnpm/package.json @@ -4,7 +4,7 @@ "dev": "webpack serve", "build": "webpack --stats-error-details", "build:prod": "webpack --mode=production", - "prebuild:ci": "pnpm install", + "prebuild:ci": "pnpm install --shamefully-hoist", "build:ci": "pnpm run build -- --no-stats", "rimraf": "rimraf dist/**/*.js" }, From d8b01075be1062965315f8d57daf4992efcd7879 Mon Sep 17 00:00:00 2001 From: bigopon Date: Thu, 5 May 2022 23:33:56 +1000 Subject: [PATCH 12/17] fix(tests): pin pnpm to v6 --- .github/workflows/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index be9beef..4531193 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -81,7 +81,7 @@ jobs: - name: Prepare test PNPM run: | - npm i -g pnpm + npm i -g pnpm@6 pnpm install --shamefully-hoist - name: Test build basic app with PNPM From 4e0e0598d6b1a66a38c641d190994af5932b779c Mon Sep 17 00:00:00 2001 From: bigopon Date: Thu, 5 May 2022 23:45:13 +1000 Subject: [PATCH 13/17] chore(tests): try fix pnpm test again --- .github/workflows/action.yml | 2 +- tests/app-filesystem-cache/.npmrc | 1 + tests/app-filesystem-cache/src/app.html | 5 +++-- tests/app-filesystem-cache/src/app.ts | 6 ++++-- tests/app-filesystem-cache/src/my-component.html | 1 + tests/app-filesystem-cache/src/my-component.ts | 2 ++ tests/app-pnpm/package.json | 2 +- 7 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 tests/app-filesystem-cache/.npmrc create mode 100644 tests/app-filesystem-cache/src/my-component.html create mode 100644 tests/app-filesystem-cache/src/my-component.ts diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index 4531193..e03a935 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -82,7 +82,7 @@ jobs: - name: Prepare test PNPM run: | npm i -g pnpm@6 - pnpm install --shamefully-hoist + pnpm install - name: Test build basic app with PNPM working-directory: ./tests/app-pnpm diff --git a/tests/app-filesystem-cache/.npmrc b/tests/app-filesystem-cache/.npmrc new file mode 100644 index 0000000..9cf9495 --- /dev/null +++ b/tests/app-filesystem-cache/.npmrc @@ -0,0 +1 @@ +package-lock=false \ No newline at end of file diff --git a/tests/app-filesystem-cache/src/app.html b/tests/app-filesystem-cache/src/app.html index 06ac72d..9065944 100644 --- a/tests/app-filesystem-cache/src/app.html +++ b/tests/app-filesystem-cache/src/app.html @@ -1,3 +1,4 @@ +

Hello World

+ + \ No newline at end of file diff --git a/tests/app-filesystem-cache/src/app.ts b/tests/app-filesystem-cache/src/app.ts index a362efa..26abaa2 100644 --- a/tests/app-filesystem-cache/src/app.ts +++ b/tests/app-filesystem-cache/src/app.ts @@ -1,3 +1,5 @@ +import { MyComponent } from "my-component"; + export class App { - appDate: Date = new Date(); -} \ No newline at end of file + viewModel = MyComponent; +} diff --git a/tests/app-filesystem-cache/src/my-component.html b/tests/app-filesystem-cache/src/my-component.html new file mode 100644 index 0000000..5987f1c --- /dev/null +++ b/tests/app-filesystem-cache/src/my-component.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/app-filesystem-cache/src/my-component.ts b/tests/app-filesystem-cache/src/my-component.ts new file mode 100644 index 0000000..36da421 --- /dev/null +++ b/tests/app-filesystem-cache/src/my-component.ts @@ -0,0 +1,2 @@ +export class MyComponent { +} \ No newline at end of file diff --git a/tests/app-pnpm/package.json b/tests/app-pnpm/package.json index 623ace6..99c857e 100644 --- a/tests/app-pnpm/package.json +++ b/tests/app-pnpm/package.json @@ -4,7 +4,7 @@ "dev": "webpack serve", "build": "webpack --stats-error-details", "build:prod": "webpack --mode=production", - "prebuild:ci": "pnpm install --shamefully-hoist", + "prebuild:ci": "pnpm install", "build:ci": "pnpm run build -- --no-stats", "rimraf": "rimraf dist/**/*.js" }, From 906e25a0867f765b9dd1ef6f29f97e346c7940fa Mon Sep 17 00:00:00 2001 From: "elias.stocker" Date: Fri, 6 May 2022 15:13:36 +0200 Subject: [PATCH 14/17] serialize preserveModuleName on NormalModule --- dist/AureliaDependenciesPlugin.js | 13 +------------ dist/IncludeDependency.js | 8 +++----- dist/PreserveModuleNamePlugin.js | 23 +++++++++++++++++++++++ dist/types/ClassSerializer.d.ts | 9 +++++---- src/AureliaDependenciesPlugin.ts | 14 +------------- src/IncludeDependency.ts | 6 ++---- src/PreserveModuleNamePlugin.ts | 25 +++++++++++++++++++++++++ 7 files changed, 60 insertions(+), 38 deletions(-) diff --git a/dist/AureliaDependenciesPlugin.js b/dist/AureliaDependenciesPlugin.js index 8cc89ab..45c12c7 100644 --- a/dist/AureliaDependenciesPlugin.js +++ b/dist/AureliaDependenciesPlugin.js @@ -10,7 +10,6 @@ const TAP_NAME = "Aurelia:Dependencies"; class AureliaDependency extends IncludeDependency_1.IncludeDependency { constructor(request, range, options) { super(request, options); - this.request = request; this.range = range; } get type() { @@ -19,18 +18,8 @@ class AureliaDependency extends IncludeDependency_1.IncludeDependency { get [PreserveExportsPlugin_1.dependencyImports]() { return webpack.Dependency.EXPORTS_OBJECT_REFERENCED; } - serialize(context) { - const { write } = context; - write(this.range); - super.serialize(context); - } - deserialize(context) { - const { read } = context; - this.range = read(); - super.deserialize(context); - } } -webpack.util.serialization.register(AureliaDependency, "AureliaDependency", null, new ClassSerializer_1.ClassSerializer(AureliaDependency)); +webpack.util.serialization.register(AureliaDependency, "AureliaDependency", "AureliaDependency", new ClassSerializer_1.ClassSerializer(AureliaDependency)); class Template { apply(dep, source) { source.replace(dep.range[0], dep.range[1] - 1, "'" + dep.request.replace(/^async(?:\?[^!]*)?!/, "") + "'"); diff --git a/dist/IncludeDependency.js b/dist/IncludeDependency.js index 8bf42c2..86e0ab7 100644 --- a/dist/IncludeDependency.js +++ b/dist/IncludeDependency.js @@ -29,17 +29,15 @@ class IncludeDependency extends webpack.dependencies.ModuleDependency { return (_a = this.options) === null || _a === void 0 ? void 0 : _a.exports; } serialize(context) { - const { write } = context; - write(this.options); + context.write(this.options); super.serialize(context); } deserialize(context) { - const { read } = context; - this.options = read(); + this.options = context.read(); super.deserialize(context); } } exports.IncludeDependency = IncludeDependency; ; -webpack.util.serialization.register(IncludeDependency, "IncludeDependency", null, new ClassSerializer_1.ClassSerializer(IncludeDependency)); +webpack.util.serialization.register(IncludeDependency, "IncludeDependency", "IncludeDependency", new ClassSerializer_1.ClassSerializer(IncludeDependency)); exports.Template = webpack.dependencies.NullDependency.Template; diff --git a/dist/PreserveModuleNamePlugin.js b/dist/PreserveModuleNamePlugin.js index 6389eab..09291ff 100644 --- a/dist/PreserveModuleNamePlugin.js +++ b/dist/PreserveModuleNamePlugin.js @@ -2,6 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.PreserveModuleNamePlugin = exports.preserveModuleName = void 0; const path = require("path"); +const Webpack = require("webpack"); const logger_1 = require("./logger"); exports.preserveModuleName = Symbol(); const TAP_NAME = "Aurelia:PreserveModuleName"; @@ -16,6 +17,13 @@ class PreserveModuleNamePlugin { this.isDll = isDll; } apply(compiler) { + // Override NormalModule serializer: "preserveModuleName" should be serialized + // to ensure correct module serialization of conventional dependencies (ConventionDependenciesPlugin) + // when "webpack filesystem cache" is enabled, https://github.com/aurelia/webpack-plugin/issues/199 + const isFilesystemCacheEnabled = typeof (compiler.options.cache) != 'boolean' && compiler.options.cache.type == 'filesystem'; + if (isFilesystemCacheEnabled) { + overrideNormalModuleSerializer(); + } compiler.hooks.compilation.tap(TAP_NAME, compilation => { compilation.hooks.beforeModuleIds.tap(TAP_NAME, $modules => { let modules = Array.from($modules); @@ -177,3 +185,18 @@ function removeLoaders(request) { let lastBang = request.lastIndexOf("!"); return lastBang < 0 ? request : request.substr(lastBang + 1); } +function overrideNormalModuleSerializer() { + const originalSerialize = Webpack.NormalModule.prototype.serialize; + Webpack.NormalModule.prototype.serialize = function (context) { + context.write(this[exports.preserveModuleName]); + originalSerialize.call(this, context); + }; + const originalDeserialize = Webpack.NormalModule.prototype.deserialize; + Webpack.NormalModule.prototype.deserialize = function (context) { + const preserve = context.read(); + if (preserve) { + this[exports.preserveModuleName] = preserve; + } + originalDeserialize.call(this, context); + }; +} diff --git a/dist/types/ClassSerializer.d.ts b/dist/types/ClassSerializer.d.ts index 344d44a..3cac782 100644 --- a/dist/types/ClassSerializer.d.ts +++ b/dist/types/ClassSerializer.d.ts @@ -1,13 +1,14 @@ +import { ObjectDeserializerContext, ObjectSerializerContext } from "./webpack"; export declare class ClassSerializer { private ctor; constructor(ctor: { new (...params: any[]): T; }); - serialize(obj: T, context: any): void; - deserialize(context: any): T; + serialize(obj: T, context: ObjectSerializerContext): void; + deserialize(context: ObjectDeserializerContext): T; } interface ISerializable { - serialize(context: any): void; - deserialize(context: any): void; + serialize(context: ObjectSerializerContext): void; + deserialize(context: ObjectDeserializerContext): void; } export {}; diff --git a/src/AureliaDependenciesPlugin.ts b/src/AureliaDependenciesPlugin.ts index 3d50772..abd3add 100644 --- a/src/AureliaDependenciesPlugin.ts +++ b/src/AureliaDependenciesPlugin.ts @@ -9,7 +9,7 @@ const BasicEvaluatedExpression: $BasicEvaluatedExpression = require("webpack/lib const TAP_NAME = "Aurelia:Dependencies"; class AureliaDependency extends IncludeDependency { - constructor(public request: string, + constructor(request: string, public range: [number, number], options?: DependencyOptions) { super(request, options); @@ -22,18 +22,6 @@ class AureliaDependency extends IncludeDependency { get [dependencyImports]() { return webpack.Dependency.EXPORTS_OBJECT_REFERENCED as any; } - - serialize(context: any) { - const { write } = context; - write(this.range); - super.serialize(context); - } - - deserialize(context: any) { - const { read } = context; - this.range = read(); - super.deserialize(context); - } } webpack.util.serialization.register(AureliaDependency, "AureliaDependency", "AureliaDependency", new ClassSerializer(AureliaDependency)); diff --git a/src/IncludeDependency.ts b/src/IncludeDependency.ts index 06a3dd3..d43a0ab 100644 --- a/src/IncludeDependency.ts +++ b/src/IncludeDependency.ts @@ -33,14 +33,12 @@ export class IncludeDependency extends webpack.dependencies.ModuleDependency { } serialize(context: any) { - const { write } = context; - write(this.options); + context.write(this.options); super.serialize(context); } deserialize(context: any) { - const { read } = context; - this.options = read(); + this.options = context.read(); super.deserialize(context); } }; diff --git a/src/PreserveModuleNamePlugin.ts b/src/PreserveModuleNamePlugin.ts index db46161..3858784 100644 --- a/src/PreserveModuleNamePlugin.ts +++ b/src/PreserveModuleNamePlugin.ts @@ -18,6 +18,14 @@ export class PreserveModuleNamePlugin { } apply(compiler: Webpack.Compiler) { + // Override NormalModule serializer: "preserveModuleName" should be serialized + // to ensure correct module serialization of conventional dependencies (ConventionDependenciesPlugin) + // when "webpack filesystem cache" is enabled, https://github.com/aurelia/webpack-plugin/issues/199 + const isFilesystemCacheEnabled = typeof (compiler.options.cache) != 'boolean' && compiler.options.cache.type == 'filesystem'; + if (isFilesystemCacheEnabled) { + overrideNormalModuleSerializer(); + } + compiler.hooks.compilation.tap(TAP_NAME, compilation => { compilation.hooks.beforeModuleIds.tap(TAP_NAME, $modules => { let modules = Array.from($modules) as Webpack.NormalModule[]; @@ -189,3 +197,20 @@ function removeLoaders(request: string | undefined) { let lastBang = request.lastIndexOf("!"); return lastBang < 0 ? request : request.substr(lastBang + 1); } + +function overrideNormalModuleSerializer() { + const originalSerialize = Webpack.NormalModule.prototype.serialize; + Webpack.NormalModule.prototype.serialize = function (context) { + context.write(this[preserveModuleName]); + originalSerialize.call(this, context); + } + + const originalDeserialize = Webpack.NormalModule.prototype.deserialize; + Webpack.NormalModule.prototype.deserialize = function (context) { + const preserve = context.read(); + if (preserve) { + this[preserveModuleName] = preserve; + } + originalDeserialize.call(this, context); + } +} \ No newline at end of file From bc140498c8fb2961f11e1b0f174d310bb2b17486 Mon Sep 17 00:00:00 2001 From: "elias.stocker" Date: Fri, 6 May 2022 15:20:55 +0200 Subject: [PATCH 15/17] fix plugin when cache not set --- src/PreserveModuleNamePlugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PreserveModuleNamePlugin.ts b/src/PreserveModuleNamePlugin.ts index 3858784..018b8d2 100644 --- a/src/PreserveModuleNamePlugin.ts +++ b/src/PreserveModuleNamePlugin.ts @@ -21,7 +21,7 @@ export class PreserveModuleNamePlugin { // Override NormalModule serializer: "preserveModuleName" should be serialized // to ensure correct module serialization of conventional dependencies (ConventionDependenciesPlugin) // when "webpack filesystem cache" is enabled, https://github.com/aurelia/webpack-plugin/issues/199 - const isFilesystemCacheEnabled = typeof (compiler.options.cache) != 'boolean' && compiler.options.cache.type == 'filesystem'; + const isFilesystemCacheEnabled = typeof (compiler.options.cache) == 'object' && compiler.options.cache.type == 'filesystem'; if (isFilesystemCacheEnabled) { overrideNormalModuleSerializer(); } From 5657c746ae18012c7fb95161ef8c734f54bf1cf5 Mon Sep 17 00:00:00 2001 From: bigopon Date: Sat, 7 May 2022 08:01:46 +1000 Subject: [PATCH 16/17] fix: pnpm test ci config --- .github/workflows/action.yml | 5 +++++ dist/PreserveModuleNamePlugin.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index e03a935..b3843d8 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -79,6 +79,11 @@ jobs: with: node-version: ${{ matrix.node-version }} + - name: Install dependencies + run: | + npm ci + npx link-parent-bin -c tests + - name: Prepare test PNPM run: | npm i -g pnpm@6 diff --git a/dist/PreserveModuleNamePlugin.js b/dist/PreserveModuleNamePlugin.js index 09291ff..e430db1 100644 --- a/dist/PreserveModuleNamePlugin.js +++ b/dist/PreserveModuleNamePlugin.js @@ -20,7 +20,7 @@ class PreserveModuleNamePlugin { // Override NormalModule serializer: "preserveModuleName" should be serialized // to ensure correct module serialization of conventional dependencies (ConventionDependenciesPlugin) // when "webpack filesystem cache" is enabled, https://github.com/aurelia/webpack-plugin/issues/199 - const isFilesystemCacheEnabled = typeof (compiler.options.cache) != 'boolean' && compiler.options.cache.type == 'filesystem'; + const isFilesystemCacheEnabled = typeof (compiler.options.cache) == 'object' && compiler.options.cache.type == 'filesystem'; if (isFilesystemCacheEnabled) { overrideNormalModuleSerializer(); } From c41ce6c35b57da7de6c60b35dcf627e94c368bfa Mon Sep 17 00:00:00 2001 From: bigopon Date: Sat, 7 May 2022 08:49:05 +1000 Subject: [PATCH 17/17] chore: add karma test for file cache --- .github/workflows/action.yml | 7 +- dist/AureliaDependenciesPlugin.js | 2 - dist/IncludeDependency.js | 10 -- dist/PreserveModuleNamePlugin.js | 23 ----- dist/types/IncludeDependency.d.ts | 2 - src/PreserveModuleNamePlugin.ts | 5 + tests/app-filesystem-cache/karma.conf.js | 103 +++++++++++++++++++ tests/app-filesystem-cache/package.json | 3 +- tests/app-filesystem-cache/src/app.ts | 2 +- tests/app-filesystem-cache/test/app.test.ts | 18 ++++ tests/app-filesystem-cache/webpack.config.js | 5 +- tests/app-simple/package.json | 2 +- 12 files changed, 140 insertions(+), 42 deletions(-) create mode 100644 tests/app-filesystem-cache/karma.conf.js create mode 100644 tests/app-filesystem-cache/test/app.test.ts diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index b3843d8..0ea5c60 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -50,7 +50,12 @@ jobs: - name: Test caching working-directory: ./tests/app-filesystem-cache - run: npm run build:ci + run: | + npm run build:ci + npm run test + # run it twice to to use cache 2nd run (hopefully?) + npm run test + Write-Host ( Get-ChildItem .\node_modules\.bin | Measure-Object ).Count; # - name: Test build app using 3rd party lib # working-directory: ./tests/app-plugin-3rd-party diff --git a/dist/AureliaDependenciesPlugin.js b/dist/AureliaDependenciesPlugin.js index 45c12c7..584d726 100644 --- a/dist/AureliaDependenciesPlugin.js +++ b/dist/AureliaDependenciesPlugin.js @@ -2,7 +2,6 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.AureliaDependenciesPlugin = void 0; const IncludeDependency_1 = require("./IncludeDependency"); -const ClassSerializer_1 = require("./ClassSerializer"); const webpack = require("webpack"); const PreserveExportsPlugin_1 = require("./PreserveExportsPlugin"); const BasicEvaluatedExpression = require("webpack/lib/javascript/BasicEvaluatedExpression"); @@ -19,7 +18,6 @@ class AureliaDependency extends IncludeDependency_1.IncludeDependency { return webpack.Dependency.EXPORTS_OBJECT_REFERENCED; } } -webpack.util.serialization.register(AureliaDependency, "AureliaDependency", "AureliaDependency", new ClassSerializer_1.ClassSerializer(AureliaDependency)); class Template { apply(dep, source) { source.replace(dep.range[0], dep.range[1] - 1, "'" + dep.request.replace(/^async(?:\?[^!]*)?!/, "") + "'"); diff --git a/dist/IncludeDependency.js b/dist/IncludeDependency.js index 86e0ab7..9cb9cc4 100644 --- a/dist/IncludeDependency.js +++ b/dist/IncludeDependency.js @@ -4,7 +4,6 @@ exports.Template = exports.IncludeDependency = void 0; const PreserveExportsPlugin_1 = require("./PreserveExportsPlugin"); const PreserveModuleNamePlugin_1 = require("./PreserveModuleNamePlugin"); const webpack = require("webpack"); -const ClassSerializer_1 = require("./ClassSerializer"); class IncludeDependency extends webpack.dependencies.ModuleDependency { constructor(request, options) { let chunk = options && options.chunk; @@ -28,16 +27,7 @@ class IncludeDependency extends webpack.dependencies.ModuleDependency { var _a; return (_a = this.options) === null || _a === void 0 ? void 0 : _a.exports; } - serialize(context) { - context.write(this.options); - super.serialize(context); - } - deserialize(context) { - this.options = context.read(); - super.deserialize(context); - } } exports.IncludeDependency = IncludeDependency; ; -webpack.util.serialization.register(IncludeDependency, "IncludeDependency", "IncludeDependency", new ClassSerializer_1.ClassSerializer(IncludeDependency)); exports.Template = webpack.dependencies.NullDependency.Template; diff --git a/dist/PreserveModuleNamePlugin.js b/dist/PreserveModuleNamePlugin.js index e430db1..6389eab 100644 --- a/dist/PreserveModuleNamePlugin.js +++ b/dist/PreserveModuleNamePlugin.js @@ -2,7 +2,6 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.PreserveModuleNamePlugin = exports.preserveModuleName = void 0; const path = require("path"); -const Webpack = require("webpack"); const logger_1 = require("./logger"); exports.preserveModuleName = Symbol(); const TAP_NAME = "Aurelia:PreserveModuleName"; @@ -17,13 +16,6 @@ class PreserveModuleNamePlugin { this.isDll = isDll; } apply(compiler) { - // Override NormalModule serializer: "preserveModuleName" should be serialized - // to ensure correct module serialization of conventional dependencies (ConventionDependenciesPlugin) - // when "webpack filesystem cache" is enabled, https://github.com/aurelia/webpack-plugin/issues/199 - const isFilesystemCacheEnabled = typeof (compiler.options.cache) == 'object' && compiler.options.cache.type == 'filesystem'; - if (isFilesystemCacheEnabled) { - overrideNormalModuleSerializer(); - } compiler.hooks.compilation.tap(TAP_NAME, compilation => { compilation.hooks.beforeModuleIds.tap(TAP_NAME, $modules => { let modules = Array.from($modules); @@ -185,18 +177,3 @@ function removeLoaders(request) { let lastBang = request.lastIndexOf("!"); return lastBang < 0 ? request : request.substr(lastBang + 1); } -function overrideNormalModuleSerializer() { - const originalSerialize = Webpack.NormalModule.prototype.serialize; - Webpack.NormalModule.prototype.serialize = function (context) { - context.write(this[exports.preserveModuleName]); - originalSerialize.call(this, context); - }; - const originalDeserialize = Webpack.NormalModule.prototype.deserialize; - Webpack.NormalModule.prototype.deserialize = function (context) { - const preserve = context.read(); - if (preserve) { - this[exports.preserveModuleName] = preserve; - } - originalDeserialize.call(this, context); - }; -} diff --git a/dist/types/IncludeDependency.d.ts b/dist/types/IncludeDependency.d.ts index de1b58e..eb26592 100644 --- a/dist/types/IncludeDependency.d.ts +++ b/dist/types/IncludeDependency.d.ts @@ -9,8 +9,6 @@ export declare class IncludeDependency extends webpack.dependencies.ModuleDepend getReferencedExports(moduleGraph: webpack.ModuleGraph): (string[] | ReferencedExport)[]; get [preserveModuleName](): boolean; get [dependencyImports](): string[] | undefined; - serialize(context: any): void; - deserialize(context: any): void; } export declare type NullDependencyTemplate = typeof webpack.dependencies.NullDependency.Template; export declare const Template: NullDependencyTemplate; diff --git a/src/PreserveModuleNamePlugin.ts b/src/PreserveModuleNamePlugin.ts index 018b8d2..ef8cc13 100644 --- a/src/PreserveModuleNamePlugin.ts +++ b/src/PreserveModuleNamePlugin.ts @@ -198,7 +198,12 @@ function removeLoaders(request: string | undefined) { return lastBang < 0 ? request : request.substr(lastBang + 1); } +let overridden = false; function overrideNormalModuleSerializer() { + if (overridden) { + return; + } + overridden = true; const originalSerialize = Webpack.NormalModule.prototype.serialize; Webpack.NormalModule.prototype.serialize = function (context) { context.write(this[preserveModuleName]); diff --git a/tests/app-filesystem-cache/karma.conf.js b/tests/app-filesystem-cache/karma.conf.js new file mode 100644 index 0000000..9d00e8f --- /dev/null +++ b/tests/app-filesystem-cache/karma.conf.js @@ -0,0 +1,103 @@ +const path = require('path'); +// const os = require('os'); +const { AureliaPlugin } = require('aurelia-webpack-plugin'); + +module.exports = (config) => { + config.set({ + basePath: '', + + preprocessors: { + // add webpack as preprocessor + 'test/**/*.test.ts': ['webpack', 'sourcemap'] + }, + + // make sure to include webpack as a framework + frameworks: ['mocha', 'webpack'], + + plugins: [ + 'karma-mocha', + 'karma-webpack', + 'karma-chrome-launcher', + 'karma-sourcemap-loader', + ], + + files: [ + { pattern: 'src/**/*.ts', included: false, served: true, watched: false, nocache: false }, + { pattern: 'test/**/*.test.ts', watched: false }, + ], + + browsers: ['ChromeHeadless'], + mime: { + "text/x-typescript": ["ts"] + }, + mochaReporter: { + ignoreSkipped: true + }, + + webpack: webpackConfig(), + }); +} + +/** + * @returns {import('webpack').Configuration} + */ +function webpackConfig() { + return { + mode: 'development', + // target: ['es5'], + // output: { + // filename: 'app.js', + // path: path.join(os.tmpdir(), '_karma_webpack_') + Math.floor(Math.random() * 1000000), + // }, + stats: { + modules: false, + colors: true, + }, + resolve: { + extensions: [".js", ".ts"], + alias: { + src: path.join(__dirname, 'src') + }, + modules: ['node_modules'] + }, + watch: true, + devtool: 'inline-source-map', + optimization: { + runtimeChunk: 'single', + splitChunks: { + chunks: 'all', + minSize: 0, + cacheGroups: { + commons: { + name: 'commons', + chunks: 'initial', + minChunks: 1, + }, + }, + }, + }, + module: { + rules: [ + { + test: /\.ts$/, + loader: "ts-loader", + exclude: /node_modules/, + options: { + compilerOptions: { + target: 'es5' + } + } + }, + { + test: /\.html$/, + loader: 'html-loader' + } + ] + }, + plugins: [ + new AureliaPlugin({ + aureliaApp: undefined + }), + ], + }; +} diff --git a/tests/app-filesystem-cache/package.json b/tests/app-filesystem-cache/package.json index 4b47771..2ad12d5 100644 --- a/tests/app-filesystem-cache/package.json +++ b/tests/app-filesystem-cache/package.json @@ -7,7 +7,8 @@ "prebuild:ci": "npm install", "build:ci": "npm run build -- --no-stats", "install:plugin": "npm install ../../", - "rimraf": "rimraf dist/**/*.js" + "rimraf": "rimraf dist/**/*.js", + "test": "karma start --singleRun" }, "dependencies": { "aurelia-webpack-plugin": "file:../.." diff --git a/tests/app-filesystem-cache/src/app.ts b/tests/app-filesystem-cache/src/app.ts index 26abaa2..c86c64e 100644 --- a/tests/app-filesystem-cache/src/app.ts +++ b/tests/app-filesystem-cache/src/app.ts @@ -1,4 +1,4 @@ -import { MyComponent } from "my-component"; +import { MyComponent } from "./my-component"; export class App { viewModel = MyComponent; diff --git a/tests/app-filesystem-cache/test/app.test.ts b/tests/app-filesystem-cache/test/app.test.ts new file mode 100644 index 0000000..ede66d5 --- /dev/null +++ b/tests/app-filesystem-cache/test/app.test.ts @@ -0,0 +1,18 @@ +import 'aurelia-polyfills'; +import 'aurelia-loader-webpack'; +import { bootstrap } from 'aurelia-bootstrapper'; +import { StageComponent } from 'aurelia-testing'; +import { assert } from 'chai'; +import { PLATFORM } from 'aurelia-pal'; + +describe('app-filesystem-cache/app.test.ts', function () { + it('works', async function () { + const component = StageComponent + .withResources([PLATFORM.moduleName('src/app')]) + .inView('') + .boundTo({ }); + await component.create(bootstrap); + + assert.include(component.element.textContent.trim(), 'Test'); + }); +}); diff --git a/tests/app-filesystem-cache/webpack.config.js b/tests/app-filesystem-cache/webpack.config.js index 900aa45..26bb026 100644 --- a/tests/app-filesystem-cache/webpack.config.js +++ b/tests/app-filesystem-cache/webpack.config.js @@ -13,7 +13,10 @@ module.exports = (env = {}) => { mode: 'development', target: 'web', cache: { - type: 'filesystem' + type: 'filesystem', + buildDependencies: { + config: [__filename] + } }, resolve: { extensions: [".ts", ".js"], diff --git a/tests/app-simple/package.json b/tests/app-simple/package.json index ccbf19c..5568b52 100644 --- a/tests/app-simple/package.json +++ b/tests/app-simple/package.json @@ -8,7 +8,7 @@ "build:ci": "npm run build -- --no-stats", "install:plugin": "npm install ../../", "rimraf": "rimraf dist/**/*.js", - "test": "../../node_modules/.bin/karma start --singleRun" + "test": "karma start --singleRun" }, "dependencies": { "aurelia-webpack-plugin": "file:../.."