From 4d486c9c64877505876a5cde2bc83d97dca36b23 Mon Sep 17 00:00:00 2001 From: bigopon Date: Sat, 7 May 2022 09:03:46 +1000 Subject: [PATCH] chore(release): prepare release 5.0.4 --- dist/AureliaDependenciesPlugin.js | 2 ++ dist/IncludeDependency.js | 10 ++++++++++ dist/PreserveModuleNamePlugin.js | 28 ++++++++++++++++++++++++++++ dist/types/IncludeDependency.d.ts | 2 ++ doc/CHANGELOG.md | 4 ++++ package-lock.json | 4 ++-- package.json | 5 +++-- 7 files changed, 51 insertions(+), 4 deletions(-) diff --git a/dist/AureliaDependenciesPlugin.js b/dist/AureliaDependenciesPlugin.js index 584d726..45c12c7 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"); @@ -18,6 +19,7 @@ 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 9cb9cc4..86e0ab7 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,16 @@ 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 6389eab..9fedd50 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) == '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); @@ -177,3 +185,23 @@ function removeLoaders(request) { let lastBang = request.lastIndexOf("!"); 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[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 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; diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index c356223..a16a078 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -1,3 +1,7 @@ +## 5.0.4 + +Fix webpack serialization when a component module is imported via the normal way + ## 5.0.3 Fix webpack v5.52.0 error with mini-css-extract-plugin diff --git a/package-lock.json b/package-lock.json index 54e21b1..8ee4d76 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "aurelia-webpack-plugin", - "version": "5.0.3", + "version": "5.0.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "aurelia-webpack-plugin", - "version": "5.0.3", + "version": "5.0.4", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index ac9b856..33a40ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aurelia-webpack-plugin", - "version": "5.0.3", + "version": "5.0.4", "description": "A plugin for webpack that enables bundling Aurelia applications.", "keywords": [ "aurelia", @@ -35,7 +35,8 @@ "build:watch": "tsc --watch", "test": "cd tests/app-basic && npm run build:ci", "preversion": "npm run test", - "version": "npm run build && git add ." + "version": "npm run build && git add .", + "cut-release": "npm version --git-tag-version false --" }, "repository": { "type": "git",