@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,89 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.createTypescriptContext = createTypescriptContext;
|
|
14
|
+
exports.transformTypescript = transformTypescript;
|
|
15
|
+
const node_path_1 = require("node:path");
|
|
16
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
17
|
+
// Test transform helpers.
|
|
18
|
+
const basefileName = 'test-file.ts';
|
|
19
|
+
function createTypescriptContext(content, additionalFiles, useLibs = false, extraCompilerOptions = {}, jsxFile = false) {
|
|
20
|
+
const fileName = basefileName + (jsxFile ? 'x' : '');
|
|
21
|
+
// Set compiler options.
|
|
22
|
+
const compilerOptions = {
|
|
23
|
+
noEmitOnError: useLibs,
|
|
24
|
+
allowJs: true,
|
|
25
|
+
newLine: typescript_1.default.NewLineKind.LineFeed,
|
|
26
|
+
moduleResolution: typescript_1.default.ModuleResolutionKind.Node10,
|
|
27
|
+
module: typescript_1.default.ModuleKind.ES2020,
|
|
28
|
+
target: typescript_1.default.ScriptTarget.ES2020,
|
|
29
|
+
skipLibCheck: true,
|
|
30
|
+
sourceMap: false,
|
|
31
|
+
importHelpers: true,
|
|
32
|
+
experimentalDecorators: true,
|
|
33
|
+
types: [],
|
|
34
|
+
...extraCompilerOptions,
|
|
35
|
+
};
|
|
36
|
+
// Create compiler host.
|
|
37
|
+
const compilerHost = typescript_1.default.createCompilerHost(compilerOptions, true);
|
|
38
|
+
const baseFileExists = compilerHost.fileExists;
|
|
39
|
+
compilerHost.fileExists = function (compilerFileName) {
|
|
40
|
+
return (compilerFileName === fileName ||
|
|
41
|
+
!!additionalFiles?.[(0, node_path_1.basename)(compilerFileName)] ||
|
|
42
|
+
baseFileExists(compilerFileName));
|
|
43
|
+
};
|
|
44
|
+
const baseReadFile = compilerHost.readFile;
|
|
45
|
+
compilerHost.readFile = function (compilerFileName) {
|
|
46
|
+
if (compilerFileName === fileName) {
|
|
47
|
+
return content;
|
|
48
|
+
}
|
|
49
|
+
else if (additionalFiles?.[(0, node_path_1.basename)(compilerFileName)]) {
|
|
50
|
+
return additionalFiles[(0, node_path_1.basename)(compilerFileName)];
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return baseReadFile(compilerFileName);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
// Create the TypeScript program.
|
|
57
|
+
const program = typescript_1.default.createProgram([fileName], compilerOptions, compilerHost);
|
|
58
|
+
return { compilerHost, program };
|
|
59
|
+
}
|
|
60
|
+
function transformTypescript(content, transformers, program, compilerHost) {
|
|
61
|
+
// Use given context or create a new one.
|
|
62
|
+
if (content !== undefined) {
|
|
63
|
+
const typescriptContext = createTypescriptContext(content);
|
|
64
|
+
if (!program) {
|
|
65
|
+
program = typescriptContext.program;
|
|
66
|
+
}
|
|
67
|
+
if (!compilerHost) {
|
|
68
|
+
compilerHost = typescriptContext.compilerHost;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else if (!program || !compilerHost) {
|
|
72
|
+
throw new Error('transformTypescript needs either `content` or a `program` and `compilerHost');
|
|
73
|
+
}
|
|
74
|
+
const outputFileName = basefileName.replace(/\.tsx?$/, '.js');
|
|
75
|
+
let outputContent;
|
|
76
|
+
// Emit.
|
|
77
|
+
const { emitSkipped, diagnostics } = program.emit(undefined, (filename, data) => {
|
|
78
|
+
if (filename === outputFileName) {
|
|
79
|
+
outputContent = data;
|
|
80
|
+
}
|
|
81
|
+
}, undefined, undefined, { before: transformers });
|
|
82
|
+
// Throw error with diagnostics if emit wasn't successfull.
|
|
83
|
+
if (emitSkipped) {
|
|
84
|
+
throw new Error(typescript_1.default.formatDiagnostics(diagnostics, compilerHost));
|
|
85
|
+
}
|
|
86
|
+
// Return the transpiled js.
|
|
87
|
+
return outputContent;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=spec_helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec_helpers.js","sourceRoot":"","sources":["spec_helpers.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;AAQH,0DAsDC;AAED,kDAyCC;AAvGD,yCAAqC;AACrC,4DAA4B;AAE5B,0BAA0B;AAC1B,MAAM,YAAY,GAAG,cAAc,CAAC;AAEpC,SAAgB,uBAAuB,CACrC,OAAe,EACf,eAAwC,EACxC,OAAO,GAAG,KAAK,EACf,uBAA2C,EAAE,EAC7C,OAAO,GAAG,KAAK;IAKf,MAAM,QAAQ,GAAG,YAAY,GAAG,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