piral-ng 1.5.6-beta.7106 → 1.5.6-beta.7114
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/compiler-dynamic.js +70 -0
- package/extend-webpack.js +19 -7
- package/package.json +7 -3
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import info from '@angular/compiler/package.json';
|
|
2
|
+
|
|
3
|
+
if (typeof window.ngVersions === 'undefined') {
|
|
4
|
+
window.ngVersions = {};
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const defaultVersion = 'default';
|
|
8
|
+
const existing = Object.getOwnPropertyDescriptor(window, 'ng');
|
|
9
|
+
|
|
10
|
+
function setUrl(url, version) {
|
|
11
|
+
if (version) {
|
|
12
|
+
window.ngVersions[url] = version;
|
|
13
|
+
return version;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return defaultVersion;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
setUrl(new URL('.', __system_context__.meta.url).href, info.version);
|
|
20
|
+
|
|
21
|
+
if (existing?.get === undefined) {
|
|
22
|
+
const ngs = {
|
|
23
|
+
[defaultVersion]: existing?.value,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function getUrl() {
|
|
27
|
+
const { stack } = new Error();
|
|
28
|
+
const lines = stack?.split('\n') || [];
|
|
29
|
+
|
|
30
|
+
if (lines[0] === 'Error') {
|
|
31
|
+
// V8
|
|
32
|
+
const line = lines[3] || '';
|
|
33
|
+
return /\((.*):\d+:\d+\)$/.exec(line)?.[1] || '';
|
|
34
|
+
} else {
|
|
35
|
+
// SpiderMonkey and JavaScriptCore
|
|
36
|
+
const line = lines[2] || '';
|
|
37
|
+
return /@(.*):\d+:\d+$/.exec(line)?.[1] || '';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function getNgVersion(url) {
|
|
42
|
+
const version = window.ngVersions[url];
|
|
43
|
+
|
|
44
|
+
if (!version) {
|
|
45
|
+
try {
|
|
46
|
+
const baseUrl = new URL('.', url);
|
|
47
|
+
const baseVersion = window.ngVersions[baseUrl.href];
|
|
48
|
+
return setUrl(url, baseVersion);
|
|
49
|
+
} catch {
|
|
50
|
+
return defaultVersion;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return version;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
Object.defineProperty(window, 'ng', {
|
|
58
|
+
configurable: true,
|
|
59
|
+
get() {
|
|
60
|
+
const url = getUrl();
|
|
61
|
+
const version = getNgVersion(url);
|
|
62
|
+
return ngs[version];
|
|
63
|
+
},
|
|
64
|
+
set(value) {
|
|
65
|
+
const url = getUrl();
|
|
66
|
+
const version = getNgVersion(url);
|
|
67
|
+
ngs[version] = value;
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
package/extend-webpack.js
CHANGED
|
@@ -101,18 +101,30 @@ module.exports =
|
|
|
101
101
|
);
|
|
102
102
|
|
|
103
103
|
if (jitMode) {
|
|
104
|
-
// The job of this plugin is
|
|
105
|
-
//
|
|
106
|
-
//
|
|
107
|
-
//
|
|
104
|
+
// The job of this plugin is
|
|
105
|
+
// (1)
|
|
106
|
+
// to make @angular/core depend on @angular/compiler - this way @angular/compiler
|
|
107
|
+
// does not need to be loaded separately and @angular/compiler is present *before*
|
|
108
|
+
// @angular/core; this is only required in jit mode - as otherwise everything should
|
|
109
|
+
// be pre-compiled.
|
|
110
|
+
// (2)
|
|
111
|
+
// to introduce a dynamic version of the window.ng global, which supports running
|
|
112
|
+
// with multiple versions of Angular.
|
|
108
113
|
config.plugins.push({
|
|
109
114
|
apply(compiler) {
|
|
110
115
|
const { entry } = compiler.options;
|
|
111
|
-
const
|
|
116
|
+
const coreEntry = entry['angular-core'];
|
|
112
117
|
|
|
113
|
-
if (typeof
|
|
118
|
+
if (typeof coreEntry !== 'undefined') {
|
|
114
119
|
const compilerDependency = resolve(__dirname, 'core-dynamic.js');
|
|
115
|
-
|
|
120
|
+
coreEntry.import = [compilerDependency, ...coreEntry.import];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const compilerEntry = entry['angular-compiler'];
|
|
124
|
+
|
|
125
|
+
if (typeof compilerEntry !== 'undefined') {
|
|
126
|
+
const compilerDependency = resolve(__dirname, 'compiler-dynamic.js');
|
|
127
|
+
compilerEntry.import = [compilerDependency, ...compilerEntry.import];
|
|
116
128
|
}
|
|
117
129
|
},
|
|
118
130
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-ng",
|
|
3
|
-
"version": "1.5.6-beta.
|
|
3
|
+
"version": "1.5.6-beta.7114",
|
|
4
4
|
"description": "Plugin for integrating Angular components in Piral.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"piral",
|
|
@@ -27,6 +27,9 @@
|
|
|
27
27
|
"./common": {
|
|
28
28
|
"import": "./common.js"
|
|
29
29
|
},
|
|
30
|
+
"./compiler-dynamic": {
|
|
31
|
+
"import": "./compiler-dynamic.js"
|
|
32
|
+
},
|
|
30
33
|
"./convert": {
|
|
31
34
|
"import": "./convert.js"
|
|
32
35
|
},
|
|
@@ -58,6 +61,7 @@
|
|
|
58
61
|
"src",
|
|
59
62
|
"common.d.ts",
|
|
60
63
|
"common.js",
|
|
64
|
+
"compiler-dynamic.js",
|
|
61
65
|
"convert.d.ts",
|
|
62
66
|
"convert.js",
|
|
63
67
|
"core-dynamic.js",
|
|
@@ -90,9 +94,9 @@
|
|
|
90
94
|
"@angular/platform-browser": "^16.0.0",
|
|
91
95
|
"@angular/platform-browser-dynamic": "^16.0.0",
|
|
92
96
|
"@angular/router": "^16.0.0",
|
|
93
|
-
"piral-core": "1.5.6-beta.
|
|
97
|
+
"piral-core": "1.5.6-beta.7114",
|
|
94
98
|
"piral-ng-common": "^16.0.0",
|
|
95
99
|
"rxjs": "^7.3.0"
|
|
96
100
|
},
|
|
97
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "aa8dcfe0f2f197ced33f525ee86bbf041f5e280f"
|
|
98
102
|
}
|