@ngtools/webpack 14.0.0-next.11 → 14.0.0-next.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/ivy/plugin.d.ts +1 -0
- package/src/ivy/plugin.js +3 -2
- package/src/resource_loader.js +6 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngtools/webpack",
|
|
3
|
-
"version": "14.0.0-next.
|
|
3
|
+
"version": "14.0.0-next.12",
|
|
4
4
|
"description": "Webpack plugin that AoT compiles your Angular components and modules.",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"typings": "src/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@angular/compiler-cli": "^14.0.0 || ^14.0.0-next",
|
|
30
30
|
"typescript": "~4.6.2",
|
|
31
|
-
"webpack": "^5.
|
|
31
|
+
"webpack": "^5.54.0"
|
|
32
32
|
},
|
|
33
33
|
"engines": {
|
|
34
34
|
"node": "^14.15.0 || >=16.10.0",
|
package/src/ivy/plugin.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export declare class AngularWebpackPlugin {
|
|
|
27
27
|
private builder?;
|
|
28
28
|
private sourceFileCache?;
|
|
29
29
|
private webpackCache?;
|
|
30
|
+
private webpackCreateHash?;
|
|
30
31
|
private readonly fileDependencies;
|
|
31
32
|
private readonly requiredFilesToEmit;
|
|
32
33
|
private readonly requiredFilesToEmitCache;
|
package/src/ivy/plugin.js
CHANGED
|
@@ -32,7 +32,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
33
|
exports.AngularWebpackPlugin = void 0;
|
|
34
34
|
const assert_1 = require("assert");
|
|
35
|
-
const crypto_1 = require("crypto");
|
|
36
35
|
const ts = __importStar(require("typescript"));
|
|
37
36
|
const ngcc_processor_1 = require("../ngcc_processor");
|
|
38
37
|
const paths_plugin_1 = require("../paths-plugin");
|
|
@@ -101,6 +100,7 @@ class AngularWebpackPlugin {
|
|
|
101
100
|
// eslint-disable-next-line max-lines-per-function
|
|
102
101
|
apply(compiler) {
|
|
103
102
|
const { NormalModuleReplacementPlugin, util } = compiler.webpack;
|
|
103
|
+
this.webpackCreateHash = util.createHash;
|
|
104
104
|
// Setup file replacements with webpack
|
|
105
105
|
for (const [key, value] of Object.entries(this.pluginOptions.fileReplacements)) {
|
|
106
106
|
new NormalModuleReplacementPlugin(new RegExp('^' + key.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&') + '$'), value).apply(compiler);
|
|
@@ -533,9 +533,10 @@ class AngularWebpackPlugin {
|
|
|
533
533
|
this.compilerNgccModule = await new Function(`return import('@angular/compiler-cli/ngcc');`)();
|
|
534
534
|
}
|
|
535
535
|
async addFileEmitHistory(filePath, content) {
|
|
536
|
+
assert_1.strict.ok(this.webpackCreateHash, 'File emitter is used prior to Webpack compilation');
|
|
536
537
|
const historyData = {
|
|
537
538
|
length: content.length,
|
|
538
|
-
hash:
|
|
539
|
+
hash: this.webpackCreateHash('xxhash64').update(content).digest(),
|
|
539
540
|
};
|
|
540
541
|
if (this.webpackCache) {
|
|
541
542
|
const history = await this.getFileEmitHistory(filePath);
|
package/src/resource_loader.js
CHANGED
|
@@ -31,7 +31,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
31
31
|
};
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
33
|
exports.WebpackResourceLoader = void 0;
|
|
34
|
-
const crypto_1 = require("crypto");
|
|
35
34
|
const path = __importStar(require("path"));
|
|
36
35
|
const vm = __importStar(require("vm"));
|
|
37
36
|
const paths_1 = require("./ivy/paths");
|
|
@@ -94,10 +93,13 @@ class WebpackResourceLoader {
|
|
|
94
93
|
setAffectedResources(file, resources) {
|
|
95
94
|
this._reverseDependencies.set(file, new Set(resources));
|
|
96
95
|
}
|
|
96
|
+
// eslint-disable-next-line max-lines-per-function
|
|
97
97
|
async _compile(filePath, data, fileExtension, resourceType, containingFile) {
|
|
98
98
|
if (!this._parentCompilation) {
|
|
99
99
|
throw new Error('WebpackResourceLoader cannot be used without parentCompilation');
|
|
100
100
|
}
|
|
101
|
+
const { context, webpack } = this._parentCompilation.compiler;
|
|
102
|
+
const { EntryPlugin, NormalModule, library, node, sources, util: { createHash }, } = webpack;
|
|
101
103
|
const getEntry = () => {
|
|
102
104
|
if (filePath) {
|
|
103
105
|
return `${filePath}?${replace_resources_1.NG_COMPONENT_RESOURCE_QUERY}`;
|
|
@@ -110,7 +112,9 @@ class WebpackResourceLoader {
|
|
|
110
112
|
}
|
|
111
113
|
else if (data) {
|
|
112
114
|
// Create a special URL for reading the resource from memory
|
|
113
|
-
return `angular-resource:${resourceType},${
|
|
115
|
+
return `angular-resource:${resourceType},${createHash('xxhash64')
|
|
116
|
+
.update(data)
|
|
117
|
+
.digest('hex')}`;
|
|
114
118
|
}
|
|
115
119
|
throw new Error(`"filePath", "resourceType" or "data" must be specified.`);
|
|
116
120
|
};
|
|
@@ -128,8 +132,6 @@ class WebpackResourceLoader {
|
|
|
128
132
|
name: 'resource',
|
|
129
133
|
},
|
|
130
134
|
};
|
|
131
|
-
const { context, webpack } = this._parentCompilation.compiler;
|
|
132
|
-
const { EntryPlugin, NormalModule, library, node, sources } = webpack;
|
|
133
135
|
const childCompiler = this._parentCompilation.createChildCompiler('angular-compiler:resource', outputOptions, [
|
|
134
136
|
new node.NodeTemplatePlugin(outputOptions),
|
|
135
137
|
new node.NodeTargetPlugin(),
|