@lwrjs/esbuild 0.13.0-alpha.9 → 0.13.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/build/cjs/index.cjs +8 -3
- package/build/es/index.js +12 -4
- package/package.json +6 -6
package/build/cjs/index.cjs
CHANGED
|
@@ -29,6 +29,8 @@ __export(exports, {
|
|
|
29
29
|
var import_fs = __toModule(require("fs"));
|
|
30
30
|
var import_path = __toModule(require("path"));
|
|
31
31
|
var import_esbuild = __toModule(require("esbuild"));
|
|
32
|
+
var import_url = __toModule(require("url"));
|
|
33
|
+
var import_os = __toModule(require("os"));
|
|
32
34
|
var esbuild = import_esbuild.default;
|
|
33
35
|
if (!import_esbuild.default) {
|
|
34
36
|
try {
|
|
@@ -64,10 +66,10 @@ var ESBUILD_EXTENSION_PLUGIN = function(absFilePath, format) {
|
|
|
64
66
|
async function transpileTs(tsAbsPath, {rootDir, cacheDir}) {
|
|
65
67
|
const format = isCommonJs ? "cjs" : "esm";
|
|
66
68
|
const ext = format === "esm" ? ".mjs" : ".cjs";
|
|
67
|
-
const pathRelativeToRoot =
|
|
68
|
-
const outBasename = pathRelativeToRoot.replace(
|
|
69
|
+
const pathRelativeToRoot = (0, import_path.relative)(rootDir, tsAbsPath);
|
|
70
|
+
const outBasename = pathRelativeToRoot.replace(new RegExp(`\\${import_path.sep}`, "g"), "_");
|
|
69
71
|
const outFilename = outBasename.replace(/\.ts$/, ext);
|
|
70
|
-
|
|
72
|
+
let outfile = (0, import_path.join)(cacheDir, outFilename);
|
|
71
73
|
await esbuild.build({
|
|
72
74
|
format,
|
|
73
75
|
bundle: true,
|
|
@@ -77,5 +79,8 @@ async function transpileTs(tsAbsPath, {rootDir, cacheDir}) {
|
|
|
77
79
|
outfile,
|
|
78
80
|
plugins: [ESBUILD_EXTENSION_PLUGIN(tsAbsPath, format)]
|
|
79
81
|
});
|
|
82
|
+
if (import_os.default.platform() === "win32") {
|
|
83
|
+
outfile = (0, import_url.pathToFileURL)(outfile).href;
|
|
84
|
+
}
|
|
80
85
|
return outfile;
|
|
81
86
|
}
|
package/build/es/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
import { join, dirname, extname } from 'path';
|
|
2
|
+
import { join, dirname, extname, relative, sep } from 'path';
|
|
3
3
|
import esbuildEsm from 'esbuild';
|
|
4
|
+
import { pathToFileURL } from 'url';
|
|
5
|
+
import os from 'os';
|
|
4
6
|
// https://github.com/evanw/esbuild/issues/706
|
|
5
7
|
// Fixed in 0.11.0 but upgrading past 0.9.7 has caused breaking changes for consumers...
|
|
6
8
|
// https://github.com/salesforce-experience-platform-emu/lwr/issues/1014
|
|
@@ -52,10 +54,10 @@ const ESBUILD_EXTENSION_PLUGIN = function (absFilePath, format) {
|
|
|
52
54
|
export async function transpileTs(tsAbsPath, { rootDir, cacheDir }) {
|
|
53
55
|
const format = isCommonJs ? 'cjs' : 'esm';
|
|
54
56
|
const ext = format === 'esm' ? '.mjs' : '.cjs';
|
|
55
|
-
const pathRelativeToRoot =
|
|
56
|
-
const outBasename = pathRelativeToRoot.replace(
|
|
57
|
+
const pathRelativeToRoot = relative(rootDir, tsAbsPath);
|
|
58
|
+
const outBasename = pathRelativeToRoot.replace(new RegExp(`\\${sep}`, 'g'), '_'); // replace "/" with "_" in path
|
|
57
59
|
const outFilename = outBasename.replace(/\.ts$/, ext);
|
|
58
|
-
|
|
60
|
+
let outfile = join(cacheDir, outFilename);
|
|
59
61
|
await esbuild.build({
|
|
60
62
|
format,
|
|
61
63
|
bundle: true,
|
|
@@ -65,6 +67,12 @@ export async function transpileTs(tsAbsPath, { rootDir, cacheDir }) {
|
|
|
65
67
|
outfile,
|
|
66
68
|
plugins: [ESBUILD_EXTENSION_PLUGIN(tsAbsPath, format)],
|
|
67
69
|
});
|
|
70
|
+
// Only URLs with a scheme in: file, data, and node are supported by the default ESM loader
|
|
71
|
+
// On Windows, absolute paths must be valid file:// URLs.
|
|
72
|
+
// Without this code for windows, dynamic imports will fail in modules.ts
|
|
73
|
+
if (os.platform() === 'win32') {
|
|
74
|
+
outfile = pathToFileURL(outfile).href;
|
|
75
|
+
}
|
|
68
76
|
return outfile;
|
|
69
77
|
}
|
|
70
78
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.13.0
|
|
7
|
+
"version": "0.13.0",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -31,18 +31,18 @@
|
|
|
31
31
|
],
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "tsc -b",
|
|
34
|
-
"clean": "
|
|
34
|
+
"clean": "rimraf build node_modules",
|
|
35
35
|
"test": "jest"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@lwrjs/types": "0.13.0
|
|
38
|
+
"@lwrjs/types": "0.13.0",
|
|
39
39
|
"jest": "^26.6.3",
|
|
40
40
|
"ts-jest": "^26.5.6",
|
|
41
41
|
"typescript": "^4.9.5"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@lwrjs/diagnostics": "0.13.0
|
|
45
|
-
"@lwrjs/shared-utils": "0.13.0
|
|
44
|
+
"@lwrjs/diagnostics": "0.13.0",
|
|
45
|
+
"@lwrjs/shared-utils": "0.13.0",
|
|
46
46
|
"esbuild": "^0.9.7"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"volta": {
|
|
52
52
|
"extends": "../../../package.json"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "21dc6b8ffd2e633f36b46daf9e1563992c5143b9"
|
|
55
55
|
}
|