@lwrjs/npm-module-provider 0.12.0-alpha.3 → 0.12.0-alpha.30
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/build/cjs/resolveNpmModules.cjs +30 -15
- package/build/es/resolveNpmModules.js +44 -27
- package/package.json +5 -5
|
@@ -56,23 +56,38 @@ async function resolveNpmModuleSpecifierBlock(specifier, dest, config) {
|
|
|
56
56
|
let res;
|
|
57
57
|
try {
|
|
58
58
|
let pkgVersion;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
59
|
+
try {
|
|
60
|
+
res = import_resolve.default.sync(specifier, {
|
|
61
|
+
packageFilter: function(pkg) {
|
|
62
|
+
const {exports: exports2, browser} = pkg;
|
|
63
|
+
if (exports2 && exports2["."]) {
|
|
64
|
+
const root = exports2["."];
|
|
65
|
+
pkg.main = root?.browser?.import || root?.browser?.default || (typeof root?.browser === "string" ? root.browser : void 0) || root?.import?.browser?.default || root?.import?.default || (typeof root?.import === "string" ? root.import : void 0) || root?.default;
|
|
66
|
+
} else if (browser && typeof browser === "string") {
|
|
67
|
+
pkg.main = pkg.browser;
|
|
68
|
+
} else if (pkg.module) {
|
|
69
|
+
pkg.main = pkg.module;
|
|
70
|
+
}
|
|
71
|
+
if (pkg.version) {
|
|
72
|
+
pkgVersion = pkg.version;
|
|
73
|
+
}
|
|
74
|
+
return pkg;
|
|
72
75
|
}
|
|
73
|
-
|
|
76
|
+
});
|
|
77
|
+
} catch (error) {
|
|
78
|
+
if (error.code === "MODULE_NOT_FOUND") {
|
|
79
|
+
import_diagnostics.logger.debug({
|
|
80
|
+
label: "npm-module-provider",
|
|
81
|
+
message: `Failed to resolve ${specifier} from npm`,
|
|
82
|
+
additionalInfo: {cause: error}
|
|
83
|
+
});
|
|
84
|
+
return void 0;
|
|
74
85
|
}
|
|
75
|
-
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
if (!res) {
|
|
89
|
+
return void 0;
|
|
90
|
+
}
|
|
76
91
|
if (pkgVersion === void 0) {
|
|
77
92
|
throw new Error("Failed to find version in package.json");
|
|
78
93
|
}
|
|
@@ -32,33 +32,50 @@ export async function resolveNpmModuleSpecifierBlock(specifier, dest, config) {
|
|
|
32
32
|
let res;
|
|
33
33
|
try {
|
|
34
34
|
let pkgVersion;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
root?.browser?.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
35
|
+
try {
|
|
36
|
+
res = resolve.sync(specifier, {
|
|
37
|
+
packageFilter: function (pkg) {
|
|
38
|
+
const { exports, browser } = pkg;
|
|
39
|
+
if (exports && exports['.']) {
|
|
40
|
+
const root = exports['.'];
|
|
41
|
+
pkg.main =
|
|
42
|
+
root?.browser?.import ||
|
|
43
|
+
root?.browser?.default ||
|
|
44
|
+
(typeof root?.browser === 'string' ? root.browser : undefined) ||
|
|
45
|
+
root?.import?.browser?.default ||
|
|
46
|
+
root?.import?.default ||
|
|
47
|
+
(typeof root?.import === 'string' ? root.import : undefined) ||
|
|
48
|
+
root?.default;
|
|
49
|
+
}
|
|
50
|
+
else if (browser && typeof browser === 'string') {
|
|
51
|
+
pkg.main = pkg.browser;
|
|
52
|
+
}
|
|
53
|
+
else if (pkg.module) {
|
|
54
|
+
pkg.main = pkg.module;
|
|
55
|
+
}
|
|
56
|
+
// grab package.json version (if set) before we go
|
|
57
|
+
if (pkg.version) {
|
|
58
|
+
pkgVersion = pkg.version;
|
|
59
|
+
}
|
|
60
|
+
return pkg;
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
// Just return undefined from resolve module not found
|
|
66
|
+
if (error.code === 'MODULE_NOT_FOUND') {
|
|
67
|
+
logger.debug({
|
|
68
|
+
label: 'npm-module-provider',
|
|
69
|
+
message: `Failed to resolve ${specifier} from npm`,
|
|
70
|
+
additionalInfo: { cause: error },
|
|
71
|
+
});
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
if (!res) {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
62
79
|
// ensure package version is set
|
|
63
80
|
if (pkgVersion === undefined) {
|
|
64
81
|
throw new Error('Failed to find version in package.json');
|
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.30",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
|
|
39
|
-
"@lwrjs/diagnostics": "0.12.0-alpha.
|
|
40
|
-
"@lwrjs/shared-utils": "0.12.0-alpha.
|
|
39
|
+
"@lwrjs/diagnostics": "0.12.0-alpha.30",
|
|
40
|
+
"@lwrjs/shared-utils": "0.12.0-alpha.30",
|
|
41
41
|
"esbuild": "^0.9.7",
|
|
42
42
|
"resolve": "^1.22.8"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@lwrjs/types": "0.12.0-alpha.
|
|
45
|
+
"@lwrjs/types": "0.12.0-alpha.30",
|
|
46
46
|
"jest": "^26.6.3",
|
|
47
47
|
"ts-jest": "^26.5.6"
|
|
48
48
|
},
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"volta": {
|
|
53
53
|
"extends": "../../../package.json"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "5273cb7ece90a3a28645cb1dfde9d315548605db"
|
|
56
56
|
}
|