@michijs/dev-server 0.8.1 → 0.8.2-beta.1
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { config } from "../../config/config.js";
|
|
2
2
|
import { minifyXMLLike } from "../../utils/minify.js";
|
|
3
|
-
import {
|
|
3
|
+
import { workerTransformer } from "../../utils/workerTransformer.js";
|
|
4
4
|
import { transformSync as esbuild } from "esbuild";
|
|
5
5
|
export const jsAndTsRegex = /.*\.(?:ts|js)/;
|
|
6
6
|
export const notJsAndTsRegex = /.*\.(?!ts|js)/;
|
|
@@ -25,7 +25,7 @@ export const transformers = [
|
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
fileRegex: jsAndTsRegex,
|
|
28
|
-
transformer:
|
|
28
|
+
transformer: workerTransformer,
|
|
29
29
|
pathTransformer: (destPath) => destPath.replace(".ts", ".js"),
|
|
30
30
|
},
|
|
31
31
|
cssTransformer,
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { config } from "../config/config.js";
|
|
2
2
|
import { getAllFiles } from "./getAllFiles.js";
|
|
3
|
-
import {
|
|
3
|
+
import { buildSync as esbuild } from "esbuild";
|
|
4
4
|
import { getCurrentCommitSha } from "./getCurrentCommitSha.js";
|
|
5
5
|
const commitSha = getCurrentCommitSha();
|
|
6
|
-
export const
|
|
7
|
-
const {
|
|
6
|
+
export const workerTransformer = (_serviceWorkerCode, srcPath) => {
|
|
7
|
+
const { outdir, define } = config.esbuildOptions;
|
|
8
8
|
try {
|
|
9
9
|
const allFiles = getAllFiles(outdir, ".");
|
|
10
|
-
const result = esbuild(
|
|
10
|
+
const result = esbuild({
|
|
11
|
+
...config.esbuildOptions,
|
|
12
|
+
splitting: false,
|
|
13
|
+
outdir: undefined,
|
|
14
|
+
inject: undefined,
|
|
15
|
+
plugins: undefined,
|
|
16
|
+
write: false,
|
|
17
|
+
entryPoints: [srcPath],
|
|
18
|
+
legalComments: "inline",
|
|
11
19
|
define: {
|
|
12
20
|
"michiProcess.env.BUILD_FILES": `${JSON.stringify(allFiles)}`,
|
|
13
21
|
// Time at GMT+0
|
|
@@ -16,19 +24,11 @@ export const serviceWorkerTransformer = (serviceWorkerCode) => {
|
|
|
16
24
|
: `"${new Date(new Date().toLocaleString("en-US", { timeZone: "Etc/GMT" })).getTime()}"`,
|
|
17
25
|
...define,
|
|
18
26
|
},
|
|
19
|
-
loader: "ts",
|
|
20
|
-
logLevel: "error",
|
|
21
|
-
format,
|
|
22
|
-
target,
|
|
23
|
-
sourcemap,
|
|
24
|
-
minifySyntax: config.public.minify,
|
|
25
|
-
minifyWhitespace: config.public.minify,
|
|
26
|
-
keepNames,
|
|
27
27
|
});
|
|
28
|
-
return result.
|
|
28
|
+
return result.outputFiles?.[0].text ?? "";
|
|
29
29
|
}
|
|
30
30
|
catch (ex) {
|
|
31
|
-
console.
|
|
31
|
+
console.error(ex);
|
|
32
32
|
throw ex;
|
|
33
33
|
}
|
|
34
34
|
};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const serviceWorkerTransformer: (serviceWorkerCode: string) => string | Buffer;
|