@depup/ngtools__webpack 21.2.2-depup.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 +21 -0
- package/README.md +25 -0
- package/changes.json +5 -0
- package/index.d.ts +8 -0
- package/index.js +25 -0
- package/index.js.map +1 -0
- package/package.json +50 -0
- package/src/benchmark.d.ts +9 -0
- package/src/benchmark.js +27 -0
- package/src/benchmark.js.map +1 -0
- package/src/index.d.ts +8 -0
- package/src/index.js +19 -0
- package/src/index.js.map +1 -0
- package/src/ivy/cache.d.ts +14 -0
- package/src/ivy/cache.js +33 -0
- package/src/ivy/cache.js.map +1 -0
- package/src/ivy/diagnostics.d.ts +13 -0
- package/src/ivy/diagnostics.js +33 -0
- package/src/ivy/diagnostics.js.map +1 -0
- package/src/ivy/host.d.ts +32 -0
- package/src/ivy/host.js +226 -0
- package/src/ivy/host.js.map +1 -0
- package/src/ivy/index.d.ts +10 -0
- package/src/ivy/index.js +17 -0
- package/src/ivy/index.js.map +1 -0
- package/src/ivy/loader.d.ts +10 -0
- package/src/ivy/loader.js +95 -0
- package/src/ivy/loader.js.map +1 -0
- package/src/ivy/paths.d.ts +11 -0
- package/src/ivy/paths.js +70 -0
- package/src/ivy/paths.js.map +1 -0
- package/src/ivy/plugin.d.ts +53 -0
- package/src/ivy/plugin.js +556 -0
- package/src/ivy/plugin.js.map +1 -0
- package/src/ivy/symbol.d.ts +25 -0
- package/src/ivy/symbol.js +45 -0
- package/src/ivy/symbol.js.map +1 -0
- package/src/ivy/system.d.ts +15 -0
- package/src/ivy/system.js +115 -0
- package/src/ivy/system.js.map +1 -0
- package/src/ivy/transformation.d.ts +18 -0
- package/src/ivy/transformation.js +137 -0
- package/src/ivy/transformation.js.map +1 -0
- package/src/loaders/inline-resource.d.ts +16 -0
- package/src/loaders/inline-resource.js +25 -0
- package/src/loaders/inline-resource.js.map +1 -0
- package/src/paths-plugin.d.ts +32 -0
- package/src/paths-plugin.js +255 -0
- package/src/paths-plugin.js.map +1 -0
- package/src/resource_loader.d.ts +29 -0
- package/src/resource_loader.js +321 -0
- package/src/resource_loader.js.map +1 -0
- package/src/transformers/elide_imports.d.ts +9 -0
- package/src/transformers/elide_imports.js +165 -0
- package/src/transformers/elide_imports.js.map +1 -0
- package/src/transformers/find_image_domains.d.ts +9 -0
- package/src/transformers/find_image_domains.js +132 -0
- package/src/transformers/find_image_domains.js.map +1 -0
- package/src/transformers/index.d.ts +9 -0
- package/src/transformers/index.js +26 -0
- package/src/transformers/index.js.map +1 -0
- package/src/transformers/remove-ivy-jit-support-calls.d.ts +9 -0
- package/src/transformers/remove-ivy-jit-support-calls.js +136 -0
- package/src/transformers/remove-ivy-jit-support-calls.js.map +1 -0
- package/src/transformers/replace_resources.d.ts +11 -0
- package/src/transformers/replace_resources.js +250 -0
- package/src/transformers/replace_resources.js.map +1 -0
- package/src/transformers/spec_helpers.d.ts +13 -0
- package/src/transformers/spec_helpers.js +89 -0
- package/src/transformers/spec_helpers.js.map +1 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import * as ts from 'typescript';
|
|
9
|
+
import { Compiler } from 'webpack';
|
|
10
|
+
export type InputFileSystem = NonNullable<Compiler['inputFileSystem']>;
|
|
11
|
+
export interface InputFileSystemSync extends InputFileSystem {
|
|
12
|
+
readFileSync: NonNullable<InputFileSystem['readFileSync']>;
|
|
13
|
+
statSync: NonNullable<InputFileSystem['statSync']>;
|
|
14
|
+
}
|
|
15
|
+
export declare function createWebpackSystem(input: InputFileSystemSync, currentDirectory: string): ts.System;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
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 () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.createWebpackSystem = createWebpackSystem;
|
|
44
|
+
const ts = __importStar(require("typescript"));
|
|
45
|
+
const paths_1 = require("./paths");
|
|
46
|
+
function shouldNotWrite() {
|
|
47
|
+
throw new Error('Webpack TypeScript System should not write.');
|
|
48
|
+
}
|
|
49
|
+
function createWebpackSystem(input, currentDirectory) {
|
|
50
|
+
// Webpack's CachedInputFileSystem uses the default directory separator in the paths it uses
|
|
51
|
+
// for keys to its cache. If the keys do not match then the file watcher will not purge outdated
|
|
52
|
+
// files and cause stale data to be used in the next rebuild. TypeScript always uses a `/` (POSIX)
|
|
53
|
+
// directory separator internally which is also supported with Windows system APIs. However,
|
|
54
|
+
// if file operations are performed with the non-default directory separator, the Webpack cache
|
|
55
|
+
// will contain a key that will not be purged. `externalizePath` ensures the paths are as expected.
|
|
56
|
+
const system = {
|
|
57
|
+
...ts.sys,
|
|
58
|
+
readFile(path) {
|
|
59
|
+
let data;
|
|
60
|
+
try {
|
|
61
|
+
data = input.readFileSync((0, paths_1.externalizePath)(path));
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
// Strip BOM if present
|
|
67
|
+
let start = 0;
|
|
68
|
+
if (data.length > 3 && data[0] === 0xef && data[1] === 0xbb && data[2] === 0xbf) {
|
|
69
|
+
start = 3;
|
|
70
|
+
}
|
|
71
|
+
return data.toString('utf8', start);
|
|
72
|
+
},
|
|
73
|
+
getFileSize(path) {
|
|
74
|
+
try {
|
|
75
|
+
return input.statSync((0, paths_1.externalizePath)(path)).size;
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return 0;
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
fileExists(path) {
|
|
82
|
+
try {
|
|
83
|
+
return input.statSync((0, paths_1.externalizePath)(path)).isFile();
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
directoryExists(path) {
|
|
90
|
+
try {
|
|
91
|
+
return input.statSync((0, paths_1.externalizePath)(path)).isDirectory();
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
getModifiedTime(path) {
|
|
98
|
+
try {
|
|
99
|
+
return input.statSync((0, paths_1.externalizePath)(path)).mtime;
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
getCurrentDirectory() {
|
|
106
|
+
return currentDirectory;
|
|
107
|
+
},
|
|
108
|
+
writeFile: shouldNotWrite,
|
|
109
|
+
createDirectory: shouldNotWrite,
|
|
110
|
+
deleteFile: shouldNotWrite,
|
|
111
|
+
setModifiedTime: shouldNotWrite,
|
|
112
|
+
};
|
|
113
|
+
return system;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=system.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.js","sourceRoot":"","sources":["system.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBH,kDAkEC;AAhFD,+CAAiC;AAEjC,mCAA0C;AAQ1C,SAAS,cAAc;IACrB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;AACjE,CAAC;AAED,SAAgB,mBAAmB,CACjC,KAA0B,EAC1B,gBAAwB;IAExB,4FAA4F;IAC5F,gGAAgG;IAChG,kGAAkG;IAClG,4FAA4F;IAC5F,+FAA+F;IAC/F,mGAAmG;IACnG,MAAM,MAAM,GAAc;QACxB,GAAG,EAAE,CAAC,GAAG;QACT,QAAQ,CAAC,IAAY;YACnB,IAAI,IAAI,CAAC;YACT,IAAI,CAAC;gBACH,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC,IAAA,uBAAe,EAAC,IAAI,CAAC,CAAC,CAAC;YACnD,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AS,CAAC;YACnB,CAAC;QACH,CAAC;QACD,mBAAmB;YACjB,OAAO,gBAAgB,CAAC;QAC1B,CAAC;QACD,SAAS,EAAE,cAAc;QACzB,eAAe,EAAE,cAAc;QAC/B,UAAU,EAAE,cAAc;QAC1B,eAAe,EAAE,cAAc;KAChC,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import * as ts from 'typescript';
|
|
9
|
+
export declare function createAotTransformers(builder: ts.BuilderProgram, options: {
|
|
10
|
+
emitClassMetadata?: boolean;
|
|
11
|
+
emitNgModuleScope?: boolean;
|
|
12
|
+
emitSetClassDebugInfo?: boolean;
|
|
13
|
+
}, imageDomains: Set<string>): ts.CustomTransformers;
|
|
14
|
+
export declare function createJitTransformers(builder: ts.BuilderProgram, compilerCli: typeof import('@angular/compiler-cli/private/tooling'), options: {
|
|
15
|
+
inlineStyleFileExtension?: string;
|
|
16
|
+
}): ts.CustomTransformers;
|
|
17
|
+
export declare function mergeTransformers(first: ts.CustomTransformers, second: ts.CustomTransformers): ts.CustomTransformers;
|
|
18
|
+
export declare function replaceBootstrap(getTypeChecker: () => ts.TypeChecker): ts.TransformerFactory<ts.SourceFile>;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
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 () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.createAotTransformers = createAotTransformers;
|
|
44
|
+
exports.createJitTransformers = createJitTransformers;
|
|
45
|
+
exports.mergeTransformers = mergeTransformers;
|
|
46
|
+
exports.replaceBootstrap = replaceBootstrap;
|
|
47
|
+
const ts = __importStar(require("typescript"));
|
|
48
|
+
const elide_imports_1 = require("../transformers/elide_imports");
|
|
49
|
+
const find_image_domains_1 = require("../transformers/find_image_domains");
|
|
50
|
+
const remove_ivy_jit_support_calls_1 = require("../transformers/remove-ivy-jit-support-calls");
|
|
51
|
+
const replace_resources_1 = require("../transformers/replace_resources");
|
|
52
|
+
function createAotTransformers(builder, options, imageDomains) {
|
|
53
|
+
const getTypeChecker = () => builder.getProgram().getTypeChecker();
|
|
54
|
+
const transformers = {
|
|
55
|
+
before: [(0, find_image_domains_1.findImageDomains)(imageDomains), replaceBootstrap(getTypeChecker)],
|
|
56
|
+
after: [],
|
|
57
|
+
};
|
|
58
|
+
const removeClassMetadata = !options.emitClassMetadata;
|
|
59
|
+
const removeNgModuleScope = !options.emitNgModuleScope;
|
|
60
|
+
const removeSetClassDebugInfo = !options.emitSetClassDebugInfo;
|
|
61
|
+
if (removeClassMetadata || removeNgModuleScope || removeSetClassDebugInfo) {
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
63
|
+
transformers.before.push((0, remove_ivy_jit_support_calls_1.removeIvyJitSupportCalls)(removeClassMetadata, removeNgModuleScope, removeSetClassDebugInfo, getTypeChecker));
|
|
64
|
+
}
|
|
65
|
+
return transformers;
|
|
66
|
+
}
|
|
67
|
+
function createJitTransformers(builder, compilerCli, options) {
|
|
68
|
+
const getTypeChecker = () => builder.getProgram().getTypeChecker();
|
|
69
|
+
return {
|
|
70
|
+
before: [
|
|
71
|
+
(0, replace_resources_1.replaceResources)(() => true, getTypeChecker, options.inlineStyleFileExtension),
|
|
72
|
+
compilerCli.constructorParametersDownlevelTransform(builder.getProgram()),
|
|
73
|
+
],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function mergeTransformers(first, second) {
|
|
77
|
+
const result = {};
|
|
78
|
+
if (first.before || second.before) {
|
|
79
|
+
result.before = [...(first.before || []), ...(second.before || [])];
|
|
80
|
+
}
|
|
81
|
+
if (first.after || second.after) {
|
|
82
|
+
result.after = [...(first.after || []), ...(second.after || [])];
|
|
83
|
+
}
|
|
84
|
+
if (first.afterDeclarations || second.afterDeclarations) {
|
|
85
|
+
result.afterDeclarations = [
|
|
86
|
+
...(first.afterDeclarations || []),
|
|
87
|
+
...(second.afterDeclarations || []),
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The name of the Angular platform that should be replaced within
|
|
94
|
+
* bootstrap call expressions to support AOT.
|
|
95
|
+
*/
|
|
96
|
+
const PLATFORM_BROWSER_DYNAMIC_NAME = 'platformBrowserDynamic';
|
|
97
|
+
function replaceBootstrap(getTypeChecker) {
|
|
98
|
+
return (context) => {
|
|
99
|
+
let bootstrapImport;
|
|
100
|
+
let bootstrapNamespace;
|
|
101
|
+
const replacedNodes = [];
|
|
102
|
+
const nodeFactory = context.factory;
|
|
103
|
+
const visitNode = (node) => {
|
|
104
|
+
if (ts.isCallExpression(node) && ts.isIdentifier(node.expression)) {
|
|
105
|
+
const target = node.expression;
|
|
106
|
+
if (target.text === PLATFORM_BROWSER_DYNAMIC_NAME) {
|
|
107
|
+
if (!bootstrapNamespace) {
|
|
108
|
+
bootstrapNamespace = nodeFactory.createUniqueName('__NgCli_bootstrap_');
|
|
109
|
+
bootstrapImport = nodeFactory.createImportDeclaration(undefined, nodeFactory.createImportClause(undefined, undefined, nodeFactory.createNamespaceImport(bootstrapNamespace)), nodeFactory.createStringLiteral('@angular/platform-browser'));
|
|
110
|
+
}
|
|
111
|
+
replacedNodes.push(target);
|
|
112
|
+
return nodeFactory.updateCallExpression(node, nodeFactory.createPropertyAccessExpression(bootstrapNamespace, 'platformBrowser'), node.typeArguments, node.arguments);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return ts.visitEachChild(node, visitNode, context);
|
|
116
|
+
};
|
|
117
|
+
return (sourceFile) => {
|
|
118
|
+
if (!sourceFile.text.includes(PLATFORM_BROWSER_DYNAMIC_NAME)) {
|
|
119
|
+
return sourceFile;
|
|
120
|
+
}
|
|
121
|
+
let updatedSourceFile = ts.visitEachChild(sourceFile, visitNode, context);
|
|
122
|
+
if (bootstrapImport) {
|
|
123
|
+
// Remove any unused platform browser dynamic imports
|
|
124
|
+
const removals = (0, elide_imports_1.elideImports)(updatedSourceFile, replacedNodes, getTypeChecker, context.getCompilerOptions());
|
|
125
|
+
if (removals.size > 0) {
|
|
126
|
+
updatedSourceFile = ts.visitEachChild(updatedSourceFile, (node) => (removals.has(node) ? undefined : node), context);
|
|
127
|
+
}
|
|
128
|
+
// Add new platform browser import
|
|
129
|
+
return nodeFactory.updateSourceFile(updatedSourceFile, ts.setTextRange(nodeFactory.createNodeArray([bootstrapImport, ...updatedSourceFile.statements]), sourceFile.statements));
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
return updatedSourceFile;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=transformation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformation.js","sourceRoot":"","sources":["transformation.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQH,sDA+BC;AAED,sDAeC;AAED,8CAsBC;AAQD,4CA2EC;AAjKD,+CAAiC;AACjC,iEAA6D;AAC7D,2EAAsE;AACtE,+FAAwF;AACxF,yEAAqE;AAErE,SAAgB,qBAAqB,CACnC,OAA0B,EAC1B,OAIC,EACD,YAAyB;IAEzB,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,cAAc,EAAE,CAAC;IACnE,MAAM,YAAY,GAA0B;QAC1C,MAAM,EAAE,CAAC,IAAA,qCAAgB,EAAC,YAAY,CAAC,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC;QAC1E,KAAK,EAAE,EAAE;KACV,CAAC;IAEF,MAAM,mBAAmB,GAAG,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tB,CACF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,OAAO,iBAAiB,CAAC;YAC3B,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import type { Compilation, LoaderContext } from 'webpack';
|
|
9
|
+
export declare const InlineAngularResourceLoaderPath: string;
|
|
10
|
+
export declare const InlineAngularResourceSymbol: unique symbol;
|
|
11
|
+
export interface CompilationWithInlineAngularResource extends Compilation {
|
|
12
|
+
[InlineAngularResourceSymbol]: string;
|
|
13
|
+
}
|
|
14
|
+
export default function (this: LoaderContext<{
|
|
15
|
+
data?: string;
|
|
16
|
+
}>): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.InlineAngularResourceSymbol = exports.InlineAngularResourceLoaderPath = void 0;
|
|
11
|
+
exports.default = default_1;
|
|
12
|
+
exports.InlineAngularResourceLoaderPath = __filename;
|
|
13
|
+
exports.InlineAngularResourceSymbol = Symbol('@ngtools/webpack[angular-resource]');
|
|
14
|
+
function default_1() {
|
|
15
|
+
const callback = this.async();
|
|
16
|
+
const { data } = this.getOptions();
|
|
17
|
+
if (data) {
|
|
18
|
+
callback(undefined, Buffer.from(data, 'base64').toString());
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
const content = this._compilation[exports.InlineAngularResourceSymbol];
|
|
22
|
+
callback(undefined, content);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=inline-resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline-resource.js","sourceRoot":"","sources":["inline-resource.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAcH,4BAYC;AAtBY,QAAA,+BAA+B,GAAW,UAAU,CAAC;AAErD,QAAA,2BAA2B,GAAkB,MAAM,CAC9D,oCAAoC,CACrC,CAAC;AAMF;IACE,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;IAC9B,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;IAEnC,IAAI,IAAI,EAAE,CAAC;QACT,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC9D,CAAC;SAAM,CAAC;QACN,MAAM,OAAO,GAAI,IAAI,CAAC,YAAqD,CACzE,mCAA2B,CAC5B,CAAC;QACF,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import { CompilerOptions } from 'typescript';
|
|
9
|
+
import type { Resolver } from 'webpack';
|
|
10
|
+
export interface TypeScriptPathsPluginOptions extends Pick<CompilerOptions, 'paths' | 'baseUrl'> {
|
|
11
|
+
}
|
|
12
|
+
type ResolverRequest = NonNullable<Parameters<Parameters<Resolver['resolve']>[4]>[2]>;
|
|
13
|
+
interface PathPluginResolverRequest extends ResolverRequest {
|
|
14
|
+
typescriptPathMapped?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare class TypeScriptPathsPlugin {
|
|
17
|
+
private baseUrl?;
|
|
18
|
+
private patterns?;
|
|
19
|
+
constructor(options?: TypeScriptPathsPluginOptions);
|
|
20
|
+
/**
|
|
21
|
+
* Update the plugin with new path mapping option values.
|
|
22
|
+
* The options will also be preprocessed to reduce the overhead of individual resolve actions
|
|
23
|
+
* during a build.
|
|
24
|
+
*
|
|
25
|
+
* @param options The `paths` and `baseUrl` options from TypeScript's `CompilerOptions`.
|
|
26
|
+
*/
|
|
27
|
+
update(options: TypeScriptPathsPluginOptions): void;
|
|
28
|
+
apply(resolver: Resolver): void;
|
|
29
|
+
findReplacements(originalRequest: string): IterableIterator<string>;
|
|
30
|
+
createReplacementRequests(request: PathPluginResolverRequest, originalRequest: string): IterableIterator<PathPluginResolverRequest>;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
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 () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.TypeScriptPathsPlugin = void 0;
|
|
44
|
+
const path = __importStar(require("node:path"));
|
|
45
|
+
class TypeScriptPathsPlugin {
|
|
46
|
+
baseUrl;
|
|
47
|
+
patterns;
|
|
48
|
+
constructor(options) {
|
|
49
|
+
if (options) {
|
|
50
|
+
this.update(options);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Update the plugin with new path mapping option values.
|
|
55
|
+
* The options will also be preprocessed to reduce the overhead of individual resolve actions
|
|
56
|
+
* during a build.
|
|
57
|
+
*
|
|
58
|
+
* @param options The `paths` and `baseUrl` options from TypeScript's `CompilerOptions`.
|
|
59
|
+
*/
|
|
60
|
+
update(options) {
|
|
61
|
+
this.baseUrl = options.baseUrl;
|
|
62
|
+
this.patterns = undefined;
|
|
63
|
+
if (options.paths) {
|
|
64
|
+
for (const [pattern, potentials] of Object.entries(options.paths)) {
|
|
65
|
+
// Ignore any entries that would not result in a new mapping
|
|
66
|
+
if (potentials.length === 0 || potentials.every((potential) => potential === '*')) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const starIndex = pattern.indexOf('*');
|
|
70
|
+
let prefix = pattern;
|
|
71
|
+
let suffix;
|
|
72
|
+
if (starIndex > -1) {
|
|
73
|
+
prefix = pattern.slice(0, starIndex);
|
|
74
|
+
if (starIndex < pattern.length - 1) {
|
|
75
|
+
suffix = pattern.slice(starIndex + 1);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
this.patterns ??= [];
|
|
79
|
+
this.patterns.push({
|
|
80
|
+
starIndex,
|
|
81
|
+
prefix,
|
|
82
|
+
suffix,
|
|
83
|
+
potentials: potentials.map((potential) => {
|
|
84
|
+
const potentialStarIndex = potential.indexOf('*');
|
|
85
|
+
if (potentialStarIndex === -1) {
|
|
86
|
+
return { hasStar: false, prefix: potential };
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
hasStar: true,
|
|
90
|
+
prefix: potential.slice(0, potentialStarIndex),
|
|
91
|
+
suffix: potentialStarIndex < potential.length - 1
|
|
92
|
+
? potential.slice(potentialStarIndex + 1)
|
|
93
|
+
: undefined,
|
|
94
|
+
};
|
|
95
|
+
}),
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
// Sort patterns so that exact matches take priority then largest prefix match
|
|
99
|
+
this.patterns?.sort((a, b) => {
|
|
100
|
+
if (a.starIndex === -1) {
|
|
101
|
+
return -1;
|
|
102
|
+
}
|
|
103
|
+
else if (b.starIndex === -1) {
|
|
104
|
+
return 1;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
return b.starIndex - a.starIndex;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
apply(resolver) {
|
|
113
|
+
const target = resolver.ensureHook('resolve');
|
|
114
|
+
// To support synchronous resolvers this hook cannot be promise based.
|
|
115
|
+
// Webpack supports synchronous resolution with `tap` and `tapAsync` hooks.
|
|
116
|
+
resolver
|
|
117
|
+
.getHook('described-resolve')
|
|
118
|
+
.tapAsync('TypeScriptPathsPlugin', (request, resolveContext, callback) => {
|
|
119
|
+
// Preprocessing of the options will ensure that `patterns` is either undefined or has elements to check
|
|
120
|
+
if (!this.patterns) {
|
|
121
|
+
callback();
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (!request || request.typescriptPathMapped) {
|
|
125
|
+
callback();
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const originalRequest = request.request || request.path;
|
|
129
|
+
if (!originalRequest) {
|
|
130
|
+
callback();
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
// Only work on Javascript/TypeScript issuers.
|
|
134
|
+
if (!request?.context?.issuer?.match(/\.[cm]?[jt]sx?$/)) {
|
|
135
|
+
callback();
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
// Absolute requests are not mapped
|
|
139
|
+
if (path.isAbsolute(originalRequest)) {
|
|
140
|
+
callback();
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
switch (originalRequest[0]) {
|
|
144
|
+
case '.':
|
|
145
|
+
// Relative requests are not mapped
|
|
146
|
+
callback();
|
|
147
|
+
return;
|
|
148
|
+
case '!':
|
|
149
|
+
// Ignore all webpack special requests
|
|
150
|
+
if (originalRequest.length > 1 && originalRequest[1] === '!') {
|
|
151
|
+
callback();
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
// A generator is used to limit the amount of replacements requests that need to be created.
|
|
157
|
+
// For example, if the first one resolves, any others are not needed and do not need
|
|
158
|
+
// to be created.
|
|
159
|
+
const requests = this.createReplacementRequests(request, originalRequest);
|
|
160
|
+
const tryResolve = () => {
|
|
161
|
+
const next = requests.next();
|
|
162
|
+
if (next.done) {
|
|
163
|
+
callback();
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
resolver.doResolve(target, next.value, '', resolveContext, (error, result) => {
|
|
167
|
+
if (error) {
|
|
168
|
+
callback(error);
|
|
169
|
+
}
|
|
170
|
+
else if (result) {
|
|
171
|
+
callback(undefined, result);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
tryResolve();
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
tryResolve();
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
*findReplacements(originalRequest) {
|
|
182
|
+
if (!this.patterns) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
// check if any path mapping rules are relevant
|
|
186
|
+
for (const { starIndex, prefix, suffix, potentials } of this.patterns) {
|
|
187
|
+
let partial;
|
|
188
|
+
if (starIndex === -1) {
|
|
189
|
+
// No star means an exact match is required
|
|
190
|
+
if (prefix === originalRequest) {
|
|
191
|
+
partial = '';
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
else if (starIndex === 0 && !suffix) {
|
|
195
|
+
// Everything matches a single wildcard pattern ("*")
|
|
196
|
+
partial = originalRequest;
|
|
197
|
+
}
|
|
198
|
+
else if (!suffix) {
|
|
199
|
+
// No suffix means the star is at the end of the pattern
|
|
200
|
+
if (originalRequest.startsWith(prefix)) {
|
|
201
|
+
partial = originalRequest.slice(prefix.length);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
// Star was in the middle of the pattern
|
|
206
|
+
if (originalRequest.startsWith(prefix) && originalRequest.endsWith(suffix)) {
|
|
207
|
+
partial = originalRequest.substring(prefix.length, originalRequest.length - suffix.length);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
// If request was not matched, move on to the next pattern
|
|
211
|
+
if (partial === undefined) {
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
// Create the full replacement values based on the original request and the potentials
|
|
215
|
+
// for the successfully matched pattern.
|
|
216
|
+
for (const { hasStar, prefix, suffix } of potentials) {
|
|
217
|
+
let replacement = prefix;
|
|
218
|
+
if (hasStar) {
|
|
219
|
+
replacement += partial;
|
|
220
|
+
if (suffix) {
|
|
221
|
+
replacement += suffix;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
yield replacement;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
*createReplacementRequests(request, originalRequest) {
|
|
229
|
+
for (const replacement of this.findReplacements(originalRequest)) {
|
|
230
|
+
const targetPath = path.resolve(this.baseUrl ?? '', replacement);
|
|
231
|
+
// Resolution in the original callee location, but with the updated request
|
|
232
|
+
// to point to the mapped target location.
|
|
233
|
+
yield {
|
|
234
|
+
...request,
|
|
235
|
+
request: targetPath,
|
|
236
|
+
typescriptPathMapped: true,
|
|
237
|
+
};
|
|
238
|
+
// If there is no extension. i.e. the target does not refer to an explicit
|
|
239
|
+
// file, then this is a candidate for module/package resolution.
|
|
240
|
+
const canBeModule = path.extname(targetPath) === '';
|
|
241
|
+
if (canBeModule) {
|
|
242
|
+
// Resolution in the target location, preserving the original request.
|
|
243
|
+
// This will work with the `resolve-in-package` resolution hook, supporting
|
|
244
|
+
// package exports for e.g. locally-built APF libraries.
|
|
245
|
+
yield {
|
|
246
|
+
...request,
|
|
247
|
+
path: targetPath,
|
|
248
|
+
typescriptPathMapped: true,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
exports.TypeScriptPathsPlugin = TypeScriptPathsPlugin;
|
|
255
|
+
//# sourceMappingURL=paths-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths-plugin.js","sourceRoot":"","sources":["paths-plugin.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gDAAkC;AAqBlC,MAAa,qBAAqB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