Skip to content

Commit

Permalink
chore(release): prepare release 5.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
bigopon committed May 6, 2022
1 parent 6a08665 commit 4d486c9
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 4 deletions.
2 changes: 2 additions & 0 deletions dist/AureliaDependenciesPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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(?:\?[^!]*)?!/, "") + "'");
Expand Down
10 changes: 10 additions & 0 deletions dist/IncludeDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
28 changes: 28 additions & 0 deletions dist/PreserveModuleNamePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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);
Expand Down Expand Up @@ -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);
};
}
2 changes: 2 additions & 0 deletions dist/types/IncludeDependency.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
4 changes: 4 additions & 0 deletions doc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 4d486c9

Please sign in to comment.