@ngtools/webpack 19.0.0-next.0 → 19.0.0-next.10
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/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2010-2024 Google LLC. https://angular.dev/license
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
9
|
copies of the Software, and to permit persons to whom the Software is
|
10
10
|
furnished to do so, subject to the following conditions:
|
11
11
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
copies or substantial portions of the Software.
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
14
|
|
15
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
16
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
17
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
SOFTWARE.
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ngtools/webpack",
|
3
|
-
"version": "19.0.0-next.
|
3
|
+
"version": "19.0.0-next.10",
|
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",
|
@@ -26,10 +26,10 @@
|
|
26
26
|
"homepage": "https://github.com/angular/angular-cli",
|
27
27
|
"peerDependencies": {
|
28
28
|
"@angular/compiler-cli": "^19.0.0-next.0",
|
29
|
-
"typescript": ">=5.
|
29
|
+
"typescript": ">=5.5 <5.7",
|
30
30
|
"webpack": "^5.54.0"
|
31
31
|
},
|
32
|
-
"packageManager": "yarn@4.
|
32
|
+
"packageManager": "yarn@4.5.0",
|
33
33
|
"engines": {
|
34
34
|
"node": "^18.19.1 || ^20.11.1 || >=22.0.0",
|
35
35
|
"npm": "^6.11.0 || ^7.5.6 || >=8.0.0",
|
package/src/ivy/loader.js
CHANGED
@@ -32,8 +32,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
33
33
|
exports.angularWebpackLoader = angularWebpackLoader;
|
34
34
|
exports.default = angularWebpackLoader;
|
35
|
-
exports.angularWebpackLoader = angularWebpackLoader;
|
36
|
-
exports.default = angularWebpackLoader;
|
37
35
|
const path = __importStar(require("path"));
|
38
36
|
const symbol_1 = require("./symbol");
|
39
37
|
const JS_FILE_REGEXP = /\.[cm]?js$/;
|
package/src/ivy/plugin.d.ts
CHANGED
@@ -23,6 +23,7 @@ export interface AngularWebpackPluginOptions {
|
|
23
23
|
export declare class AngularWebpackPlugin {
|
24
24
|
private readonly pluginOptions;
|
25
25
|
private compilerCliModule?;
|
26
|
+
private compilerCliToolingModule?;
|
26
27
|
private watchMode?;
|
27
28
|
private ngtscNextProgram?;
|
28
29
|
private builder?;
|
@@ -35,6 +36,7 @@ export declare class AngularWebpackPlugin {
|
|
35
36
|
private readonly fileEmitHistory;
|
36
37
|
constructor(options?: Partial<AngularWebpackPluginOptions>);
|
37
38
|
private get compilerCli();
|
39
|
+
private get compilerCliTooling();
|
38
40
|
get options(): AngularWebpackPluginOptions;
|
39
41
|
apply(compiler: Compiler): void;
|
40
42
|
private setupCompilation;
|
package/src/ivy/plugin.js
CHANGED
@@ -54,6 +54,7 @@ const compilationFileEmitters = new WeakMap();
|
|
54
54
|
class AngularWebpackPlugin {
|
55
55
|
pluginOptions;
|
56
56
|
compilerCliModule;
|
57
|
+
compilerCliToolingModule;
|
57
58
|
watchMode;
|
58
59
|
ngtscNextProgram;
|
59
60
|
builder;
|
@@ -83,11 +84,18 @@ class AngularWebpackPlugin {
|
|
83
84
|
assert_1.strict.ok(this.compilerCliModule, `'@angular/compiler-cli' used prior to Webpack compilation.`);
|
84
85
|
return this.compilerCliModule;
|
85
86
|
}
|
87
|
+
get compilerCliTooling() {
|
88
|
+
// The compilerCliToolingModule field is guaranteed to be defined during a compilation
|
89
|
+
// due to the `beforeCompile` hook. Usage of this property accessor prior to the
|
90
|
+
// hook execution is an implementation error.
|
91
|
+
assert_1.strict.ok(this.compilerCliToolingModule, `'@angular/compiler-cli' used prior to Webpack compilation.`);
|
92
|
+
return this.compilerCliToolingModule;
|
93
|
+
}
|
86
94
|
get options() {
|
87
95
|
return this.pluginOptions;
|
88
96
|
}
|
89
97
|
apply(compiler) {
|
90
|
-
const { NormalModuleReplacementPlugin,
|
98
|
+
const { NormalModuleReplacementPlugin, util } = compiler.webpack;
|
91
99
|
this.webpackCreateHash = util.createHash;
|
92
100
|
// Setup file replacements with webpack
|
93
101
|
for (const [key, value] of Object.entries(this.pluginOptions.fileReplacements)) {
|
@@ -230,7 +238,8 @@ class AngularWebpackPlugin {
|
|
230
238
|
if (!fileEmitters) {
|
231
239
|
fileEmitters = new symbol_1.FileEmitterCollection();
|
232
240
|
compilationFileEmitters.set(compilation, fileEmitters);
|
233
|
-
compilation.compiler.webpack.NormalModule.getCompilationHooks(compilation).loader.tap(PLUGIN_NAME, (
|
241
|
+
compilation.compiler.webpack.NormalModule.getCompilationHooks(compilation).loader.tap(PLUGIN_NAME, (context) => {
|
242
|
+
const loaderContext = context;
|
234
243
|
loaderContext[symbol_1.AngularPluginSymbol] = fileEmitters;
|
235
244
|
});
|
236
245
|
}
|
@@ -459,7 +468,7 @@ class AngularWebpackPlugin {
|
|
459
468
|
...builder.getSemanticDiagnostics(),
|
460
469
|
];
|
461
470
|
diagnosticsReporter(diagnostics);
|
462
|
-
const transformers = (0, transformation_1.createJitTransformers)(builder, this.
|
471
|
+
const transformers = (0, transformation_1.createJitTransformers)(builder, this.compilerCliTooling, this.pluginOptions);
|
463
472
|
return {
|
464
473
|
fileEmitter: this.createFileEmitter(builder, transformers, () => []),
|
465
474
|
builder,
|
@@ -497,9 +506,6 @@ class AngularWebpackPlugin {
|
|
497
506
|
};
|
498
507
|
}
|
499
508
|
async initializeCompilerCli() {
|
500
|
-
if (this.compilerCliModule) {
|
501
|
-
return;
|
502
|
-
}
|
503
509
|
// This uses a dynamic import to load `@angular/compiler-cli` which may be ESM.
|
504
510
|
// CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript
|
505
511
|
// will currently, unconditionally downlevel dynamic import into a require call.
|
@@ -507,7 +513,8 @@ class AngularWebpackPlugin {
|
|
507
513
|
// this, a Function constructor is used to prevent TypeScript from changing the dynamic import.
|
508
514
|
// Once TypeScript provides support for keeping the dynamic import this workaround can
|
509
515
|
// be dropped.
|
510
|
-
this.compilerCliModule
|
516
|
+
this.compilerCliModule ??= await new Function(`return import('@angular/compiler-cli');`)();
|
517
|
+
this.compilerCliToolingModule ??= await new Function(`return import('@angular/compiler-cli/private/tooling');`)();
|
511
518
|
}
|
512
519
|
async addFileEmitHistory(filePath, content) {
|
513
520
|
assert_1.strict.ok(this.webpackCreateHash, 'File emitter is used prior to Webpack compilation');
|
@@ -11,7 +11,7 @@ export declare function createAotTransformers(builder: ts.BuilderProgram, option
|
|
11
11
|
emitNgModuleScope?: boolean;
|
12
12
|
emitSetClassDebugInfo?: boolean;
|
13
13
|
}, imageDomains: Set<string>): ts.CustomTransformers;
|
14
|
-
export declare function createJitTransformers(builder: ts.BuilderProgram, compilerCli: typeof import('@angular/compiler-cli'), options: {
|
14
|
+
export declare function createJitTransformers(builder: ts.BuilderProgram, compilerCli: typeof import('@angular/compiler-cli/private/tooling'), options: {
|
15
15
|
inlineStyleFileExtension?: string;
|
16
16
|
}): ts.CustomTransformers;
|
17
17
|
export declare function mergeTransformers(first: ts.CustomTransformers, second: ts.CustomTransformers): ts.CustomTransformers;
|
@@ -5,5 +5,5 @@
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
6
6
|
* found in the LICENSE file at https://angular.dev/license
|
7
7
|
*/
|
8
|
-
import
|
8
|
+
import ts from 'typescript';
|
9
9
|
export declare function findImageDomains(imageDomains: Set<string>): ts.TransformerFactory<ts.SourceFile>;
|
@@ -6,33 +6,12 @@
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
7
7
|
* found in the LICENSE file at https://angular.dev/license
|
8
8
|
*/
|
9
|
-
var
|
10
|
-
|
11
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
12
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
13
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
14
|
-
}
|
15
|
-
Object.defineProperty(o, k2, desc);
|
16
|
-
}) : (function(o, m, k, k2) {
|
17
|
-
if (k2 === undefined) k2 = k;
|
18
|
-
o[k2] = m[k];
|
19
|
-
}));
|
20
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
21
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
22
|
-
}) : function(o, v) {
|
23
|
-
o["default"] = v;
|
24
|
-
});
|
25
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
26
|
-
if (mod && mod.__esModule) return mod;
|
27
|
-
var result = {};
|
28
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
29
|
-
__setModuleDefault(result, mod);
|
30
|
-
return result;
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
31
11
|
};
|
32
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
33
13
|
exports.findImageDomains = findImageDomains;
|
34
|
-
const
|
35
|
-
const TARGET_TEXT = '@NgModule';
|
14
|
+
const typescript_1 = __importDefault(require("typescript"));
|
36
15
|
const BUILTIN_LOADERS = new Set([
|
37
16
|
'provideCloudflareLoader',
|
38
17
|
'provideCloudinaryLoader',
|
@@ -47,105 +26,105 @@ function findImageDomains(imageDomains) {
|
|
47
26
|
return BUILTIN_LOADERS.has(node.expression.getText());
|
48
27
|
};
|
49
28
|
const findDomainString = (node) => {
|
50
|
-
if (
|
51
|
-
|
52
|
-
|
53
|
-
|
29
|
+
if (typescript_1.default.isStringLiteral(node) ||
|
30
|
+
typescript_1.default.isTemplateHead(node) ||
|
31
|
+
typescript_1.default.isTemplateMiddle(node) ||
|
32
|
+
typescript_1.default.isTemplateTail(node)) {
|
54
33
|
const domain = node.text.match(URL_REGEX);
|
55
34
|
if (domain && domain[0]) {
|
56
35
|
imageDomains.add(domain[0]);
|
57
36
|
return node;
|
58
37
|
}
|
59
38
|
}
|
60
|
-
|
39
|
+
typescript_1.default.visitEachChild(node, findDomainString, context);
|
61
40
|
return node;
|
62
41
|
};
|
63
42
|
function isImageProviderKey(property) {
|
64
|
-
return (
|
43
|
+
return (typescript_1.default.isPropertyAssignment(property) &&
|
65
44
|
property.name.getText() === 'provide' &&
|
66
45
|
property.initializer.getText() === 'IMAGE_LOADER');
|
67
46
|
}
|
68
47
|
function isImageProviderValue(property) {
|
69
|
-
return
|
48
|
+
return typescript_1.default.isPropertyAssignment(property) && property.name.getText() === 'useValue';
|
70
49
|
}
|
71
50
|
function checkForDomain(node) {
|
72
51
|
if (node.properties.find(isImageProviderKey)) {
|
73
52
|
const value = node.properties.find(isImageProviderValue);
|
74
|
-
if (value &&
|
75
|
-
if (
|
76
|
-
|
77
|
-
|
53
|
+
if (value && typescript_1.default.isPropertyAssignment(value)) {
|
54
|
+
if (typescript_1.default.isArrowFunction(value.initializer) ||
|
55
|
+
typescript_1.default.isFunctionExpression(value.initializer)) {
|
56
|
+
typescript_1.default.visitEachChild(node, findDomainString, context);
|
78
57
|
}
|
79
58
|
}
|
80
59
|
}
|
81
60
|
}
|
82
61
|
function findImageLoaders(node) {
|
83
|
-
if (
|
62
|
+
if (typescript_1.default.isCallExpression(node)) {
|
84
63
|
if (isBuiltinImageLoader(node)) {
|
85
64
|
const firstArg = node.arguments[0];
|
86
|
-
if (
|
65
|
+
if (typescript_1.default.isStringLiteralLike(firstArg)) {
|
87
66
|
imageDomains.add(firstArg.text);
|
88
67
|
}
|
89
68
|
}
|
90
69
|
}
|
91
|
-
else if (
|
70
|
+
else if (typescript_1.default.isObjectLiteralExpression(node)) {
|
92
71
|
checkForDomain(node);
|
93
72
|
}
|
94
73
|
return node;
|
95
74
|
}
|
96
75
|
function findProvidersAssignment(node) {
|
97
|
-
if (
|
98
|
-
if (
|
99
|
-
|
76
|
+
if (typescript_1.default.isPropertyAssignment(node)) {
|
77
|
+
if (typescript_1.default.isIdentifier(node.name) && node.name.escapedText === 'providers') {
|
78
|
+
typescript_1.default.visitEachChild(node.initializer, findImageLoaders, context);
|
100
79
|
}
|
101
80
|
}
|
102
81
|
return node;
|
103
82
|
}
|
104
83
|
function findFeaturesAssignment(node) {
|
105
|
-
if (
|
106
|
-
if (
|
84
|
+
if (typescript_1.default.isPropertyAssignment(node)) {
|
85
|
+
if (typescript_1.default.isIdentifier(node.name) &&
|
107
86
|
node.name.escapedText === 'features' &&
|
108
|
-
|
87
|
+
typescript_1.default.isArrayLiteralExpression(node.initializer)) {
|
109
88
|
const providerElement = node.initializer.elements.find(isProvidersFeatureElement);
|
110
89
|
if (providerElement &&
|
111
|
-
|
90
|
+
typescript_1.default.isCallExpression(providerElement) &&
|
112
91
|
providerElement.arguments[0]) {
|
113
|
-
|
92
|
+
typescript_1.default.visitEachChild(providerElement.arguments[0], findImageLoaders, context);
|
114
93
|
}
|
115
94
|
}
|
116
95
|
}
|
117
96
|
return node;
|
118
97
|
}
|
119
98
|
function isProvidersFeatureElement(node) {
|
120
|
-
return (
|
121
|
-
|
122
|
-
|
99
|
+
return (typescript_1.default.isCallExpression(node) &&
|
100
|
+
typescript_1.default.isPropertyAccessExpression(node.expression) &&
|
101
|
+
typescript_1.default.isIdentifier(node.expression.expression) &&
|
123
102
|
node.expression.expression.escapedText === 'i0' &&
|
124
|
-
|
103
|
+
typescript_1.default.isIdentifier(node.expression.name) &&
|
125
104
|
node.expression.name.escapedText === 'ɵɵProvidersFeature');
|
126
105
|
}
|
127
106
|
function findPropertyDeclaration(node) {
|
128
|
-
if (
|
129
|
-
|
107
|
+
if (typescript_1.default.isPropertyDeclaration(node) &&
|
108
|
+
typescript_1.default.isIdentifier(node.name) &&
|
130
109
|
node.initializer &&
|
131
|
-
|
110
|
+
typescript_1.default.isCallExpression(node.initializer) &&
|
132
111
|
node.initializer.arguments[0]) {
|
133
112
|
if (node.name.escapedText === 'ɵinj') {
|
134
|
-
|
113
|
+
typescript_1.default.visitEachChild(node.initializer.arguments[0], findProvidersAssignment, context);
|
135
114
|
}
|
136
115
|
else if (node.name.escapedText === 'ɵcmp') {
|
137
|
-
|
116
|
+
typescript_1.default.visitEachChild(node.initializer.arguments[0], findFeaturesAssignment, context);
|
138
117
|
}
|
139
118
|
}
|
140
119
|
return node;
|
141
120
|
}
|
142
121
|
function findClassDeclaration(node) {
|
143
|
-
if (
|
144
|
-
|
122
|
+
if (typescript_1.default.isClassDeclaration(node)) {
|
123
|
+
typescript_1.default.visitEachChild(node, findPropertyDeclaration, context);
|
145
124
|
}
|
146
125
|
return node;
|
147
126
|
}
|
148
|
-
|
127
|
+
typescript_1.default.visitEachChild(sourceFile, findClassDeclaration, context);
|
149
128
|
return sourceFile;
|
150
129
|
};
|
151
130
|
};
|