@lwrjs/module-bundler 0.12.0-alpha.26 → 0.12.0-alpha.28
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.
|
@@ -37,12 +37,13 @@ var groupieCodeCache = new Map();
|
|
|
37
37
|
function includeIdFactory(graphSpecifier, external, exclude = [], requiredImports, groups) {
|
|
38
38
|
return (moduleRef) => {
|
|
39
39
|
const moduleIsNotRoot = graphSpecifier !== moduleRef.specifier;
|
|
40
|
-
if (
|
|
40
|
+
if ((0, import_shared_utils.isExternalSpecifier)(moduleRef.specifier, {external})) {
|
|
41
41
|
moduleRef.externalSrc = external[moduleRef.specifier];
|
|
42
|
+
moduleRef.external = true;
|
|
42
43
|
if (moduleIsNotRoot) {
|
|
43
44
|
requiredImports.set(`${moduleRef.specifier}_${moduleRef.version || import_shared_utils.VERSION_NOT_PROVIDED}`, moduleRef);
|
|
45
|
+
return false;
|
|
44
46
|
}
|
|
45
|
-
return false;
|
|
46
47
|
}
|
|
47
48
|
const moduleRefIsGroupie = (0, import_shared_utils.isGroupie)(moduleRef.specifier, groups);
|
|
48
49
|
const rootModuleIsGroupie = (0, import_shared_utils.isGroupie)(graphSpecifier, groups);
|
|
@@ -125,17 +126,22 @@ async function getBundleCode(rootModule, moduleGraphs, includedModules, bundleGr
|
|
|
125
126
|
return filteredModules;
|
|
126
127
|
}, []).map((linkedDefinition) => {
|
|
127
128
|
const id = (0, import_shared_utils.getSpecifier)(linkedDefinition);
|
|
129
|
+
includeId(linkedDefinition);
|
|
130
|
+
const isExternal = linkedDefinition.external;
|
|
131
|
+
const isExternalFile = linkedDefinition.externalSrc && linkedDefinition.externalSrc.startsWith(import_shared_utils.PROTOCOL_FILE);
|
|
128
132
|
if (visitedSpecifiers?.has(id)) {
|
|
129
133
|
return false;
|
|
130
134
|
} else {
|
|
131
135
|
visitedSpecifiers?.set(id, true);
|
|
132
136
|
}
|
|
133
137
|
if (id !== rootModule) {
|
|
134
|
-
|
|
138
|
+
if (!isExternal) {
|
|
139
|
+
includedModules.push(id);
|
|
140
|
+
}
|
|
135
141
|
} else {
|
|
136
142
|
bundleGroupsIncludedModules.push(id);
|
|
137
143
|
}
|
|
138
|
-
if (
|
|
144
|
+
if (isExternalFile) {
|
|
139
145
|
return linkedDefinition.linkedSource;
|
|
140
146
|
}
|
|
141
147
|
return bundle(id, moduleGraphs, minify, unVersionedAliases);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GraphDepth, createAmdAlias, explodeSpecifier, getModuleGraphs, getSpecifier, getGroupName, isGroupie, getCacheKeyFromJson, VERSION_NOT_PROVIDED, isExternalSpecifier, } from '@lwrjs/shared-utils';
|
|
1
|
+
import { GraphDepth, createAmdAlias, explodeSpecifier, getModuleGraphs, getSpecifier, getGroupName, isGroupie, getCacheKeyFromJson, VERSION_NOT_PROVIDED, isExternalSpecifier, PROTOCOL_FILE, } from '@lwrjs/shared-utils';
|
|
2
2
|
import { rollup } from 'rollup';
|
|
3
3
|
import replace from '@rollup/plugin-replace';
|
|
4
4
|
import { BundleSpan, getTracer } from '@lwrjs/instrumentation';
|
|
@@ -11,15 +11,16 @@ function includeIdFactory(graphSpecifier, external, exclude = [], requiredImport
|
|
|
11
11
|
const moduleIsNotRoot = graphSpecifier !== moduleRef.specifier;
|
|
12
12
|
// Do not bundle externals, including the loader module, which is auto bundled
|
|
13
13
|
// with the shim + loader combo
|
|
14
|
-
if (
|
|
14
|
+
if (isExternalSpecifier(moduleRef.specifier, { external })) {
|
|
15
15
|
// Include externals just mark them as such
|
|
16
16
|
moduleRef.externalSrc = external[moduleRef.specifier];
|
|
17
|
+
moduleRef.external = true;
|
|
17
18
|
if (moduleIsNotRoot) {
|
|
18
19
|
// Include externals in the required imports
|
|
19
20
|
requiredImports.set(`${moduleRef.specifier}_${moduleRef.version || VERSION_NOT_PROVIDED}`, moduleRef);
|
|
21
|
+
// return false to indicate it should not be in the bundle
|
|
22
|
+
return false;
|
|
20
23
|
}
|
|
21
|
-
// return false to indicate it should not be in the bundle
|
|
22
|
-
return false;
|
|
23
24
|
}
|
|
24
25
|
const moduleRefIsGroupie = isGroupie(moduleRef.specifier, groups);
|
|
25
26
|
const rootModuleIsGroupie = isGroupie(graphSpecifier, groups);
|
|
@@ -121,21 +122,30 @@ async function getBundleCode(rootModule, moduleGraphs, includedModules, bundleGr
|
|
|
121
122
|
}, [])
|
|
122
123
|
.map((linkedDefinition) => {
|
|
123
124
|
const id = getSpecifier(linkedDefinition);
|
|
125
|
+
// Calling includeId will set external and external source as a side effect
|
|
126
|
+
includeId(linkedDefinition);
|
|
127
|
+
const isExternal = linkedDefinition.external;
|
|
128
|
+
const isExternalFile = linkedDefinition.externalSrc &&
|
|
129
|
+
linkedDefinition.externalSrc.startsWith(PROTOCOL_FILE);
|
|
124
130
|
if (visitedSpecifiers?.has(id)) {
|
|
125
131
|
return false;
|
|
126
132
|
}
|
|
127
133
|
else {
|
|
128
134
|
visitedSpecifiers?.set(id, true);
|
|
129
135
|
}
|
|
136
|
+
// If this is the root module we do not include it in the included modules
|
|
130
137
|
if (id !== rootModule) {
|
|
131
|
-
|
|
138
|
+
// If this is an external module do not include it as included
|
|
139
|
+
if (!isExternal) {
|
|
140
|
+
includedModules.push(id);
|
|
141
|
+
}
|
|
132
142
|
}
|
|
133
143
|
else {
|
|
134
144
|
// we need to still keep track of roots for bundle groups
|
|
135
145
|
bundleGroupsIncludedModules.push(id);
|
|
136
146
|
}
|
|
137
|
-
// If this is a external
|
|
138
|
-
if (
|
|
147
|
+
// If this is a external from a static file no need to bundle.
|
|
148
|
+
if (isExternalFile) {
|
|
139
149
|
return linkedDefinition.linkedSource;
|
|
140
150
|
}
|
|
141
151
|
// bundle all dependencies for the linked definition and convert to AMD
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.12.0-alpha.
|
|
7
|
+
"version": "0.12.0-alpha.28",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -47,14 +47,14 @@
|
|
|
47
47
|
"build/**/*.d.ts"
|
|
48
48
|
],
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@lwrjs/diagnostics": "0.12.0-alpha.
|
|
51
|
-
"@lwrjs/instrumentation": "0.12.0-alpha.
|
|
52
|
-
"@lwrjs/shared-utils": "0.12.0-alpha.
|
|
50
|
+
"@lwrjs/diagnostics": "0.12.0-alpha.28",
|
|
51
|
+
"@lwrjs/instrumentation": "0.12.0-alpha.28",
|
|
52
|
+
"@lwrjs/shared-utils": "0.12.0-alpha.28",
|
|
53
53
|
"@rollup/plugin-replace": "^2.4.2",
|
|
54
54
|
"rollup": "^2.78.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@lwrjs/types": "0.12.0-alpha.
|
|
57
|
+
"@lwrjs/types": "0.12.0-alpha.28",
|
|
58
58
|
"jest": "^26.6.3",
|
|
59
59
|
"ts-jest": "^26.5.6"
|
|
60
60
|
},
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"volta": {
|
|
71
71
|
"extends": "../../../package.json"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "5228219171bb2d28a4c7b32f1f6238e396ac3cbd"
|
|
74
74
|
}
|