@ngtools/webpack 19.0.0-next.8 → 19.0.0-rc.0
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 +5 -5
- package/package.json +1 -1
- package/src/ivy/host.d.ts +0 -1
- package/src/ivy/host.js +0 -11
- package/src/ivy/plugin.js +2 -2
- package/src/transformers/find_image_domains.d.ts +1 -1
- package/src/transformers/find_image_domains.js +37 -58
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
package/src/ivy/host.d.ts
CHANGED
@@ -28,6 +28,5 @@ export declare function augmentHostWithResources(host: ts.CompilerHost, resource
|
|
28
28
|
export declare function augmentHostWithDependencyCollection(host: ts.CompilerHost, dependencies: Map<string, Set<string>>, moduleResolutionCache?: ts.ModuleResolutionCache): void;
|
29
29
|
export declare function augmentHostWithReplacements(host: ts.CompilerHost, replacements: Record<string, string>, moduleResolutionCache?: ts.ModuleResolutionCache): void;
|
30
30
|
export declare function augmentHostWithSubstitutions(host: ts.CompilerHost, substitutions: Record<string, string>): void;
|
31
|
-
export declare function augmentHostWithVersioning(host: ts.CompilerHost): void;
|
32
31
|
export declare function augmentProgramWithVersioning(program: ts.Program): void;
|
33
32
|
export declare function augmentHostWithCaching(host: ts.CompilerHost, cache: Map<string, ts.SourceFile>): void;
|
package/src/ivy/host.js
CHANGED
@@ -34,7 +34,6 @@ exports.augmentHostWithResources = augmentHostWithResources;
|
|
34
34
|
exports.augmentHostWithDependencyCollection = augmentHostWithDependencyCollection;
|
35
35
|
exports.augmentHostWithReplacements = augmentHostWithReplacements;
|
36
36
|
exports.augmentHostWithSubstitutions = augmentHostWithSubstitutions;
|
37
|
-
exports.augmentHostWithVersioning = augmentHostWithVersioning;
|
38
37
|
exports.augmentProgramWithVersioning = augmentProgramWithVersioning;
|
39
38
|
exports.augmentHostWithCaching = augmentHostWithCaching;
|
40
39
|
const crypto_1 = require("crypto");
|
@@ -189,16 +188,6 @@ function augmentHostWithSubstitutions(host, substitutions) {
|
|
189
188
|
return file;
|
190
189
|
};
|
191
190
|
}
|
192
|
-
function augmentHostWithVersioning(host) {
|
193
|
-
const baseGetSourceFile = host.getSourceFile;
|
194
|
-
host.getSourceFile = function (...parameters) {
|
195
|
-
const file = baseGetSourceFile.call(host, ...parameters);
|
196
|
-
if (file && file.version === undefined) {
|
197
|
-
file.version = (0, crypto_1.createHash)('sha256').update(file.text).digest('hex');
|
198
|
-
}
|
199
|
-
return file;
|
200
|
-
};
|
201
|
-
}
|
202
191
|
function augmentProgramWithVersioning(program) {
|
203
192
|
const baseGetSourceFiles = program.getSourceFiles;
|
204
193
|
program.getSourceFiles = function (...parameters) {
|
package/src/ivy/plugin.js
CHANGED
@@ -95,7 +95,7 @@ class AngularWebpackPlugin {
|
|
95
95
|
return this.pluginOptions;
|
96
96
|
}
|
97
97
|
apply(compiler) {
|
98
|
-
const { NormalModuleReplacementPlugin,
|
98
|
+
const { NormalModuleReplacementPlugin, util } = compiler.webpack;
|
99
99
|
this.webpackCreateHash = util.createHash;
|
100
100
|
// Setup file replacements with webpack
|
101
101
|
for (const [key, value] of Object.entries(this.pluginOptions.fileReplacements)) {
|
@@ -468,7 +468,7 @@ class AngularWebpackPlugin {
|
|
468
468
|
...builder.getSemanticDiagnostics(),
|
469
469
|
];
|
470
470
|
diagnosticsReporter(diagnostics);
|
471
|
-
const transformers = (0, transformation_1.createJitTransformers)(builder, this.
|
471
|
+
const transformers = (0, transformation_1.createJitTransformers)(builder, this.compilerCliTooling, this.pluginOptions);
|
472
472
|
return {
|
473
473
|
fileEmitter: this.createFileEmitter(builder, transformers, () => []),
|
474
474
|
builder,
|
@@ -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
|
};
|