@modern-js/plugin-worker 2.3.1-beta.0 → 2.6.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/dist/{js/node → cjs}/constants.js +0 -7
- package/dist/cjs/index.js +129 -0
- package/dist/{js/modern → esm}/constants.js +0 -6
- package/dist/esm/index.js +104 -0
- package/dist/types/constants.d.ts +0 -1
- package/package.json +13 -12
- package/dist/js/modern/index.js +0 -133
- package/dist/js/modern/utils.js +0 -30
- package/dist/js/node/index.js +0 -148
- package/dist/js/node/utils.js +0 -59
- package/dist/js/treeshaking/code.js +0 -4
- package/dist/js/treeshaking/constants.js +0 -11
- package/dist/js/treeshaking/index.js +0 -225
- package/dist/js/treeshaking/utils.js +0 -45
- package/dist/types/utils.d.ts +0 -1
- /package/dist/{js/node → cjs}/code.js +0 -0
- /package/dist/{js/modern → esm}/code.js +0 -0
@@ -17,7 +17,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
18
|
var constants_exports = {};
|
19
19
|
__export(constants_exports, {
|
20
|
-
LOCK_FILE: () => LOCK_FILE,
|
21
20
|
MANIFEST_FILE: () => MANIFEST_FILE,
|
22
21
|
PKG_FILE: () => PKG_FILE,
|
23
22
|
WORKER_SERVER: () => WORKER_SERVER,
|
@@ -29,15 +28,9 @@ const WORKER_SERVER = "worker-server";
|
|
29
28
|
const WORKER_SERVER_ENTRY = "index.js";
|
30
29
|
const MANIFEST_FILE = "manifest.js";
|
31
30
|
const PKG_FILE = "package.json";
|
32
|
-
const LOCK_FILE = {
|
33
|
-
yarn: "yarn.lock",
|
34
|
-
npm: "package-lock.json",
|
35
|
-
pnpm: "pnpm-lock.yaml"
|
36
|
-
};
|
37
31
|
const WRANGLER_FILE = "wrangler.toml";
|
38
32
|
// Annotate the CommonJS export names for ESM import in node:
|
39
33
|
0 && (module.exports = {
|
40
|
-
LOCK_FILE,
|
41
34
|
MANIFEST_FILE,
|
42
35
|
PKG_FILE,
|
43
36
|
WORKER_SERVER,
|
@@ -0,0 +1,129 @@
|
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
+
var __export = (target, all) => {
|
8
|
+
for (var name in all)
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
10
|
+
};
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
13
|
+
for (let key of __getOwnPropNames(from))
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
|
+
}
|
17
|
+
return to;
|
18
|
+
};
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
25
|
+
mod
|
26
|
+
));
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28
|
+
var src_exports = {};
|
29
|
+
__export(src_exports, {
|
30
|
+
default: () => src_default
|
31
|
+
});
|
32
|
+
module.exports = __toCommonJS(src_exports);
|
33
|
+
var import_path = __toESM(require("path"));
|
34
|
+
var import_utils = require("@modern-js/utils");
|
35
|
+
var import_constants = require("./constants");
|
36
|
+
var import_code = require("./code");
|
37
|
+
var src_default = () => ({
|
38
|
+
name: "@modern-js/plugin-worker",
|
39
|
+
setup: (ctx) => {
|
40
|
+
return {
|
41
|
+
async config() {
|
42
|
+
return {
|
43
|
+
output: {
|
44
|
+
disableNodePolyfill: false
|
45
|
+
}
|
46
|
+
// TODO
|
47
|
+
// tools: {
|
48
|
+
// webpackChain: (chain, { isServiceWorker }) => {
|
49
|
+
// if (isServiceWorker) {
|
50
|
+
// chain.resolve.alias.set(
|
51
|
+
// 'async_hooks',
|
52
|
+
// path.resolve(__dirname, './async_hooks'),
|
53
|
+
// );
|
54
|
+
// }
|
55
|
+
// },
|
56
|
+
// },
|
57
|
+
};
|
58
|
+
},
|
59
|
+
async afterDev() {
|
60
|
+
const { appDirectory, distDirectory } = ctx.useAppContext();
|
61
|
+
const configContext = ctx.useResolvedConfigContext();
|
62
|
+
if (!(0, import_utils.isServiceWorker)(configContext)) {
|
63
|
+
return;
|
64
|
+
}
|
65
|
+
writeWorkerServerFile(appDirectory, distDirectory);
|
66
|
+
},
|
67
|
+
async afterBuild() {
|
68
|
+
const { appDirectory, distDirectory } = ctx.useAppContext();
|
69
|
+
const configContext = ctx.useResolvedConfigContext();
|
70
|
+
if (!(0, import_utils.isServiceWorker)(configContext)) {
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
writeWorkerServerFile(appDirectory, distDirectory);
|
74
|
+
}
|
75
|
+
};
|
76
|
+
}
|
77
|
+
});
|
78
|
+
const writeWorkerServerFile = (appDirectory, distDirectory) => {
|
79
|
+
const workServerDir = import_path.default.join(distDirectory, import_constants.WORKER_SERVER);
|
80
|
+
import_utils.fs.removeSync(workServerDir);
|
81
|
+
import_utils.fs.mkdirSync(workServerDir);
|
82
|
+
import_utils.fs.writeFileSync(import_path.default.join(workServerDir, import_constants.WORKER_SERVER_ENTRY), (0, import_code.worker)());
|
83
|
+
const routeJSON = import_path.default.join(distDirectory, import_utils.ROUTE_SPEC_FILE);
|
84
|
+
const { routes } = import_utils.fs.readJSONSync(routeJSON);
|
85
|
+
let importStr = ``;
|
86
|
+
let pageStr = ``;
|
87
|
+
const routeArr = [];
|
88
|
+
routes.forEach(
|
89
|
+
(route) => {
|
90
|
+
if (route.isSSR) {
|
91
|
+
importStr += `import { serverRender as ${route.entryName}ServerRender } from "../${route.worker}";
|
92
|
+
`;
|
93
|
+
}
|
94
|
+
importStr += `import ${route.entryName}template from "../${route.entryPath}";
|
95
|
+
`;
|
96
|
+
pageStr += `"${route.urlPath}": {
|
97
|
+
entryName: "${route.entryName}",
|
98
|
+
template: ${route.entryName}template,
|
99
|
+
serverRender: ${route.isSSR ? `${route.entryName}ServerRender` : void 0},
|
100
|
+
},`;
|
101
|
+
routeArr.push({
|
102
|
+
entryName: route.entryName,
|
103
|
+
isSSR: route.isSSR,
|
104
|
+
urlPath: route.urlPath
|
105
|
+
});
|
106
|
+
}
|
107
|
+
);
|
108
|
+
const manifest = `
|
109
|
+
${importStr}
|
110
|
+
|
111
|
+
export const manifest = {
|
112
|
+
pages: {
|
113
|
+
${pageStr}
|
114
|
+
},
|
115
|
+
routes: ${JSON.stringify(routeArr, null, " ")}
|
116
|
+
}
|
117
|
+
`;
|
118
|
+
import_utils.fs.writeFileSync(import_path.default.join(workServerDir, import_constants.MANIFEST_FILE), manifest);
|
119
|
+
const pkg = import_utils.fs.readJSONSync(import_path.default.join(appDirectory, import_constants.PKG_FILE));
|
120
|
+
import_utils.fs.writeFileSync(
|
121
|
+
import_path.default.join(distDirectory, import_constants.WRANGLER_FILE),
|
122
|
+
`name = "${pkg.name}"
|
123
|
+
main = "${import_path.default.join(import_constants.WORKER_SERVER, import_constants.WORKER_SERVER_ENTRY)}"
|
124
|
+
compatibility_date = "${(/* @__PURE__ */ new Date()).toISOString().substring(0, 10)}"
|
125
|
+
`
|
126
|
+
);
|
127
|
+
};
|
128
|
+
// Annotate the CommonJS export names for ESM import in node:
|
129
|
+
0 && (module.exports = {});
|
@@ -2,14 +2,8 @@ const WORKER_SERVER = "worker-server";
|
|
2
2
|
const WORKER_SERVER_ENTRY = "index.js";
|
3
3
|
const MANIFEST_FILE = "manifest.js";
|
4
4
|
const PKG_FILE = "package.json";
|
5
|
-
const LOCK_FILE = {
|
6
|
-
yarn: "yarn.lock",
|
7
|
-
npm: "package-lock.json",
|
8
|
-
pnpm: "pnpm-lock.yaml"
|
9
|
-
};
|
10
5
|
const WRANGLER_FILE = "wrangler.toml";
|
11
6
|
export {
|
12
|
-
LOCK_FILE,
|
13
7
|
MANIFEST_FILE,
|
14
8
|
PKG_FILE,
|
15
9
|
WORKER_SERVER,
|
@@ -0,0 +1,104 @@
|
|
1
|
+
import path from "path";
|
2
|
+
import { fs, isServiceWorker, ROUTE_SPEC_FILE } from "@modern-js/utils";
|
3
|
+
import {
|
4
|
+
MANIFEST_FILE,
|
5
|
+
PKG_FILE,
|
6
|
+
WORKER_SERVER,
|
7
|
+
WORKER_SERVER_ENTRY,
|
8
|
+
WRANGLER_FILE
|
9
|
+
} from "./constants";
|
10
|
+
import { worker } from "./code";
|
11
|
+
var src_default = () => ({
|
12
|
+
name: "@modern-js/plugin-worker",
|
13
|
+
setup: (ctx) => {
|
14
|
+
return {
|
15
|
+
async config() {
|
16
|
+
return {
|
17
|
+
output: {
|
18
|
+
disableNodePolyfill: false
|
19
|
+
}
|
20
|
+
// TODO
|
21
|
+
// tools: {
|
22
|
+
// webpackChain: (chain, { isServiceWorker }) => {
|
23
|
+
// if (isServiceWorker) {
|
24
|
+
// chain.resolve.alias.set(
|
25
|
+
// 'async_hooks',
|
26
|
+
// path.resolve(__dirname, './async_hooks'),
|
27
|
+
// );
|
28
|
+
// }
|
29
|
+
// },
|
30
|
+
// },
|
31
|
+
};
|
32
|
+
},
|
33
|
+
async afterDev() {
|
34
|
+
const { appDirectory, distDirectory } = ctx.useAppContext();
|
35
|
+
const configContext = ctx.useResolvedConfigContext();
|
36
|
+
if (!isServiceWorker(configContext)) {
|
37
|
+
return;
|
38
|
+
}
|
39
|
+
writeWorkerServerFile(appDirectory, distDirectory);
|
40
|
+
},
|
41
|
+
async afterBuild() {
|
42
|
+
const { appDirectory, distDirectory } = ctx.useAppContext();
|
43
|
+
const configContext = ctx.useResolvedConfigContext();
|
44
|
+
if (!isServiceWorker(configContext)) {
|
45
|
+
return;
|
46
|
+
}
|
47
|
+
writeWorkerServerFile(appDirectory, distDirectory);
|
48
|
+
}
|
49
|
+
};
|
50
|
+
}
|
51
|
+
});
|
52
|
+
const writeWorkerServerFile = (appDirectory, distDirectory) => {
|
53
|
+
const workServerDir = path.join(distDirectory, WORKER_SERVER);
|
54
|
+
fs.removeSync(workServerDir);
|
55
|
+
fs.mkdirSync(workServerDir);
|
56
|
+
fs.writeFileSync(path.join(workServerDir, WORKER_SERVER_ENTRY), worker());
|
57
|
+
const routeJSON = path.join(distDirectory, ROUTE_SPEC_FILE);
|
58
|
+
const { routes } = fs.readJSONSync(routeJSON);
|
59
|
+
let importStr = ``;
|
60
|
+
let pageStr = ``;
|
61
|
+
const routeArr = [];
|
62
|
+
routes.forEach(
|
63
|
+
(route) => {
|
64
|
+
if (route.isSSR) {
|
65
|
+
importStr += `import { serverRender as ${route.entryName}ServerRender } from "../${route.worker}";
|
66
|
+
`;
|
67
|
+
}
|
68
|
+
importStr += `import ${route.entryName}template from "../${route.entryPath}";
|
69
|
+
`;
|
70
|
+
pageStr += `"${route.urlPath}": {
|
71
|
+
entryName: "${route.entryName}",
|
72
|
+
template: ${route.entryName}template,
|
73
|
+
serverRender: ${route.isSSR ? `${route.entryName}ServerRender` : void 0},
|
74
|
+
},`;
|
75
|
+
routeArr.push({
|
76
|
+
entryName: route.entryName,
|
77
|
+
isSSR: route.isSSR,
|
78
|
+
urlPath: route.urlPath
|
79
|
+
});
|
80
|
+
}
|
81
|
+
);
|
82
|
+
const manifest = `
|
83
|
+
${importStr}
|
84
|
+
|
85
|
+
export const manifest = {
|
86
|
+
pages: {
|
87
|
+
${pageStr}
|
88
|
+
},
|
89
|
+
routes: ${JSON.stringify(routeArr, null, " ")}
|
90
|
+
}
|
91
|
+
`;
|
92
|
+
fs.writeFileSync(path.join(workServerDir, MANIFEST_FILE), manifest);
|
93
|
+
const pkg = fs.readJSONSync(path.join(appDirectory, PKG_FILE));
|
94
|
+
fs.writeFileSync(
|
95
|
+
path.join(distDirectory, WRANGLER_FILE),
|
96
|
+
`name = "${pkg.name}"
|
97
|
+
main = "${path.join(WORKER_SERVER, WORKER_SERVER_ENTRY)}"
|
98
|
+
compatibility_date = "${(/* @__PURE__ */ new Date()).toISOString().substring(0, 10)}"
|
99
|
+
`
|
100
|
+
);
|
101
|
+
};
|
102
|
+
export {
|
103
|
+
src_default as default
|
104
|
+
};
|
@@ -2,5 +2,4 @@ export declare const WORKER_SERVER = "worker-server";
|
|
2
2
|
export declare const WORKER_SERVER_ENTRY = "index.js";
|
3
3
|
export declare const MANIFEST_FILE = "manifest.js";
|
4
4
|
export declare const PKG_FILE = "package.json";
|
5
|
-
export declare const LOCK_FILE: Record<string, string>;
|
6
5
|
export declare const WRANGLER_FILE = "wrangler.toml";
|
package/package.json
CHANGED
@@ -11,18 +11,18 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "2.
|
15
|
-
"types": "./dist/types/
|
14
|
+
"version": "2.6.0",
|
15
|
+
"types": "./dist/types/index.d.ts",
|
16
16
|
"jsnext:source": "./src/index.ts",
|
17
|
-
"main": "./dist/
|
17
|
+
"main": "./dist/cjs/index.js",
|
18
18
|
"exports": {
|
19
19
|
".": {
|
20
20
|
"jsnext:source": "./src/index.ts",
|
21
|
-
"default": "./dist/
|
21
|
+
"default": "./dist/cjs/index.js"
|
22
22
|
},
|
23
23
|
"./cli": {
|
24
24
|
"jsnext:source": "./src/index.ts",
|
25
|
-
"default": "./dist/
|
25
|
+
"default": "./dist/cjs/index.js"
|
26
26
|
}
|
27
27
|
},
|
28
28
|
"typesVersions": {
|
@@ -37,19 +37,20 @@
|
|
37
37
|
},
|
38
38
|
"dependencies": {
|
39
39
|
"@babel/runtime": "^7.18.0",
|
40
|
-
"@modern-js/server-utils": "2.
|
41
|
-
"@modern-js/utils": "2.
|
40
|
+
"@modern-js/server-utils": "2.6.0",
|
41
|
+
"@modern-js/utils": "2.6.0",
|
42
|
+
"@modern-js/prod-server": "2.6.0"
|
42
43
|
},
|
43
44
|
"devDependencies": {
|
44
45
|
"typescript": "^4",
|
45
46
|
"@types/jest": "^27",
|
46
47
|
"@types/node": "^14",
|
47
48
|
"jest": "^27",
|
48
|
-
"@modern-js/app-tools": "
|
49
|
-
"@modern-js/
|
50
|
-
"@modern-js/
|
51
|
-
"@scripts/
|
52
|
-
"@scripts/
|
49
|
+
"@modern-js/app-tools": "2.6.0",
|
50
|
+
"@modern-js/types": "2.6.0",
|
51
|
+
"@modern-js/core": "2.6.0",
|
52
|
+
"@scripts/jest-config": "2.6.0",
|
53
|
+
"@scripts/build": "2.6.0"
|
53
54
|
},
|
54
55
|
"sideEffects": [
|
55
56
|
"*.css",
|
package/dist/js/modern/index.js
DELETED
@@ -1,133 +0,0 @@
|
|
1
|
-
var __async = (__this, __arguments, generator) => {
|
2
|
-
return new Promise((resolve, reject) => {
|
3
|
-
var fulfilled = (value) => {
|
4
|
-
try {
|
5
|
-
step(generator.next(value));
|
6
|
-
} catch (e) {
|
7
|
-
reject(e);
|
8
|
-
}
|
9
|
-
};
|
10
|
-
var rejected = (value) => {
|
11
|
-
try {
|
12
|
-
step(generator.throw(value));
|
13
|
-
} catch (e) {
|
14
|
-
reject(e);
|
15
|
-
}
|
16
|
-
};
|
17
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
18
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
19
|
-
});
|
20
|
-
};
|
21
|
-
import path from "path";
|
22
|
-
import {
|
23
|
-
fs,
|
24
|
-
getPackageManager,
|
25
|
-
isServiceWorker,
|
26
|
-
ROUTE_SPEC_FILE
|
27
|
-
} from "@modern-js/utils";
|
28
|
-
import {
|
29
|
-
LOCK_FILE,
|
30
|
-
MANIFEST_FILE,
|
31
|
-
PKG_FILE,
|
32
|
-
WORKER_SERVER,
|
33
|
-
WORKER_SERVER_ENTRY,
|
34
|
-
WRANGLER_FILE
|
35
|
-
} from "./constants";
|
36
|
-
import { worker } from "./code";
|
37
|
-
import { copyfile } from "./utils";
|
38
|
-
var src_default = () => ({
|
39
|
-
name: "@modern-js/plugin-worker",
|
40
|
-
setup: (ctx) => {
|
41
|
-
return {
|
42
|
-
config() {
|
43
|
-
return __async(this, null, function* () {
|
44
|
-
return {
|
45
|
-
output: {
|
46
|
-
disableNodePolyfill: false
|
47
|
-
}
|
48
|
-
};
|
49
|
-
});
|
50
|
-
},
|
51
|
-
beforeDeploy() {
|
52
|
-
return __async(this, null, function* () {
|
53
|
-
const { appDirectory, distDirectory } = ctx.useAppContext();
|
54
|
-
const configContext = ctx.useResolvedConfigContext();
|
55
|
-
if (!isServiceWorker(configContext)) {
|
56
|
-
return;
|
57
|
-
}
|
58
|
-
const workServerDir = path.join(distDirectory, WORKER_SERVER);
|
59
|
-
fs.removeSync(workServerDir);
|
60
|
-
fs.mkdirSync(workServerDir);
|
61
|
-
fs.writeFileSync(
|
62
|
-
path.join(workServerDir, WORKER_SERVER_ENTRY),
|
63
|
-
worker()
|
64
|
-
);
|
65
|
-
const routeJSON = path.join(distDirectory, ROUTE_SPEC_FILE);
|
66
|
-
const { routes } = fs.readJSONSync(routeJSON);
|
67
|
-
let importStr = ``;
|
68
|
-
let pageStr = ``;
|
69
|
-
const routeArr = [];
|
70
|
-
routes.forEach(
|
71
|
-
(route) => {
|
72
|
-
if (route.isSSR) {
|
73
|
-
importStr += `import { serverRender as ${route.entryName}ServerRender } from "../${route.worker}";
|
74
|
-
`;
|
75
|
-
}
|
76
|
-
importStr += `import ${route.entryName}template from "../${route.entryPath}";
|
77
|
-
`;
|
78
|
-
pageStr += `"${route.urlPath}": {
|
79
|
-
entryName: "${route.entryName}",
|
80
|
-
template: ${route.entryName}template,
|
81
|
-
serverRender: ${route.isSSR ? `${route.entryName}ServerRender` : void 0},
|
82
|
-
},`;
|
83
|
-
routeArr.push({
|
84
|
-
entryName: route.entryName,
|
85
|
-
isSSR: route.isSSR,
|
86
|
-
urlPath: route.urlPath
|
87
|
-
});
|
88
|
-
}
|
89
|
-
);
|
90
|
-
const manifest = `
|
91
|
-
${importStr}
|
92
|
-
|
93
|
-
export const manifest = {
|
94
|
-
pages: {
|
95
|
-
${pageStr}
|
96
|
-
},
|
97
|
-
routes: ${JSON.stringify(routeArr, null, " ")}
|
98
|
-
}
|
99
|
-
`;
|
100
|
-
fs.writeFileSync(path.join(workServerDir, MANIFEST_FILE), manifest);
|
101
|
-
const pkg = fs.readJSONSync(path.join(appDirectory, PKG_FILE));
|
102
|
-
yield fs.writeJSON(
|
103
|
-
path.join(distDirectory, PKG_FILE),
|
104
|
-
{
|
105
|
-
name: pkg.name,
|
106
|
-
version: pkg.version,
|
107
|
-
dependencies: {
|
108
|
-
"@modern-js/prod-server": "0.0.0-next-20230209112307",
|
109
|
-
wrangler: "^2.9.0"
|
110
|
-
},
|
111
|
-
resolutions: pkg.resolutions || {},
|
112
|
-
pnpm: pkg.pnpm || {}
|
113
|
-
},
|
114
|
-
{ spaces: 2 }
|
115
|
-
);
|
116
|
-
const manager = yield getPackageManager(appDirectory);
|
117
|
-
const lockfile = LOCK_FILE[manager];
|
118
|
-
copyfile(distDirectory, appDirectory, [lockfile]);
|
119
|
-
fs.writeFileSync(
|
120
|
-
path.join(distDirectory, WRANGLER_FILE),
|
121
|
-
`name = "${pkg.name}"
|
122
|
-
main = "${path.join(WORKER_SERVER, WORKER_SERVER_ENTRY)}"
|
123
|
-
compatibility_date = "${new Date().toISOString().substring(0, 10)}"
|
124
|
-
`
|
125
|
-
);
|
126
|
-
});
|
127
|
-
}
|
128
|
-
};
|
129
|
-
}
|
130
|
-
});
|
131
|
-
export {
|
132
|
-
src_default as default
|
133
|
-
};
|
package/dist/js/modern/utils.js
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
import path from "path";
|
2
|
-
import { fs } from "@modern-js/utils";
|
3
|
-
const copyfile = (target, source, fl) => {
|
4
|
-
fl.forEach((ff) => {
|
5
|
-
if (!ff) {
|
6
|
-
return;
|
7
|
-
}
|
8
|
-
if (typeof ff === "string") {
|
9
|
-
cpfile(target, source, ff);
|
10
|
-
return;
|
11
|
-
}
|
12
|
-
const sourceIncludeFiles = fs.readdirSync(source);
|
13
|
-
for (const filename of sourceIncludeFiles) {
|
14
|
-
if (ff.test(filename)) {
|
15
|
-
cpfile(target, source, filename);
|
16
|
-
}
|
17
|
-
}
|
18
|
-
});
|
19
|
-
function cpfile(target2, source2, filename) {
|
20
|
-
const filepath = path.join(source2, filename);
|
21
|
-
if (!fs.existsSync(filepath)) {
|
22
|
-
return;
|
23
|
-
}
|
24
|
-
const targetPath = path.join(target2, filename);
|
25
|
-
fs.copySync(filepath, targetPath);
|
26
|
-
}
|
27
|
-
};
|
28
|
-
export {
|
29
|
-
copyfile
|
30
|
-
};
|
package/dist/js/node/index.js
DELETED
@@ -1,148 +0,0 @@
|
|
1
|
-
var __create = Object.create;
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
-
var __export = (target, all) => {
|
8
|
-
for (var name in all)
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
10
|
-
};
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
13
|
-
for (let key of __getOwnPropNames(from))
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
|
-
}
|
17
|
-
return to;
|
18
|
-
};
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
21
|
-
mod
|
22
|
-
));
|
23
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
24
|
-
var __async = (__this, __arguments, generator) => {
|
25
|
-
return new Promise((resolve, reject) => {
|
26
|
-
var fulfilled = (value) => {
|
27
|
-
try {
|
28
|
-
step(generator.next(value));
|
29
|
-
} catch (e) {
|
30
|
-
reject(e);
|
31
|
-
}
|
32
|
-
};
|
33
|
-
var rejected = (value) => {
|
34
|
-
try {
|
35
|
-
step(generator.throw(value));
|
36
|
-
} catch (e) {
|
37
|
-
reject(e);
|
38
|
-
}
|
39
|
-
};
|
40
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
41
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
42
|
-
});
|
43
|
-
};
|
44
|
-
var src_exports = {};
|
45
|
-
__export(src_exports, {
|
46
|
-
default: () => src_default
|
47
|
-
});
|
48
|
-
module.exports = __toCommonJS(src_exports);
|
49
|
-
var import_path = __toESM(require("path"));
|
50
|
-
var import_utils = require("@modern-js/utils");
|
51
|
-
var import_constants = require("./constants");
|
52
|
-
var import_code = require("./code");
|
53
|
-
var import_utils2 = require("./utils");
|
54
|
-
var src_default = () => ({
|
55
|
-
name: "@modern-js/plugin-worker",
|
56
|
-
setup: (ctx) => {
|
57
|
-
return {
|
58
|
-
config() {
|
59
|
-
return __async(this, null, function* () {
|
60
|
-
return {
|
61
|
-
output: {
|
62
|
-
disableNodePolyfill: false
|
63
|
-
}
|
64
|
-
};
|
65
|
-
});
|
66
|
-
},
|
67
|
-
beforeDeploy() {
|
68
|
-
return __async(this, null, function* () {
|
69
|
-
const { appDirectory, distDirectory } = ctx.useAppContext();
|
70
|
-
const configContext = ctx.useResolvedConfigContext();
|
71
|
-
if (!(0, import_utils.isServiceWorker)(configContext)) {
|
72
|
-
return;
|
73
|
-
}
|
74
|
-
const workServerDir = import_path.default.join(distDirectory, import_constants.WORKER_SERVER);
|
75
|
-
import_utils.fs.removeSync(workServerDir);
|
76
|
-
import_utils.fs.mkdirSync(workServerDir);
|
77
|
-
import_utils.fs.writeFileSync(
|
78
|
-
import_path.default.join(workServerDir, import_constants.WORKER_SERVER_ENTRY),
|
79
|
-
(0, import_code.worker)()
|
80
|
-
);
|
81
|
-
const routeJSON = import_path.default.join(distDirectory, import_utils.ROUTE_SPEC_FILE);
|
82
|
-
const { routes } = import_utils.fs.readJSONSync(routeJSON);
|
83
|
-
let importStr = ``;
|
84
|
-
let pageStr = ``;
|
85
|
-
const routeArr = [];
|
86
|
-
routes.forEach(
|
87
|
-
(route) => {
|
88
|
-
if (route.isSSR) {
|
89
|
-
importStr += `import { serverRender as ${route.entryName}ServerRender } from "../${route.worker}";
|
90
|
-
`;
|
91
|
-
}
|
92
|
-
importStr += `import ${route.entryName}template from "../${route.entryPath}";
|
93
|
-
`;
|
94
|
-
pageStr += `"${route.urlPath}": {
|
95
|
-
entryName: "${route.entryName}",
|
96
|
-
template: ${route.entryName}template,
|
97
|
-
serverRender: ${route.isSSR ? `${route.entryName}ServerRender` : void 0},
|
98
|
-
},`;
|
99
|
-
routeArr.push({
|
100
|
-
entryName: route.entryName,
|
101
|
-
isSSR: route.isSSR,
|
102
|
-
urlPath: route.urlPath
|
103
|
-
});
|
104
|
-
}
|
105
|
-
);
|
106
|
-
const manifest = `
|
107
|
-
${importStr}
|
108
|
-
|
109
|
-
export const manifest = {
|
110
|
-
pages: {
|
111
|
-
${pageStr}
|
112
|
-
},
|
113
|
-
routes: ${JSON.stringify(routeArr, null, " ")}
|
114
|
-
}
|
115
|
-
`;
|
116
|
-
import_utils.fs.writeFileSync(import_path.default.join(workServerDir, import_constants.MANIFEST_FILE), manifest);
|
117
|
-
const pkg = import_utils.fs.readJSONSync(import_path.default.join(appDirectory, import_constants.PKG_FILE));
|
118
|
-
yield import_utils.fs.writeJSON(
|
119
|
-
import_path.default.join(distDirectory, import_constants.PKG_FILE),
|
120
|
-
{
|
121
|
-
name: pkg.name,
|
122
|
-
version: pkg.version,
|
123
|
-
dependencies: {
|
124
|
-
"@modern-js/prod-server": "0.0.0-next-20230209112307",
|
125
|
-
wrangler: "^2.9.0"
|
126
|
-
},
|
127
|
-
resolutions: pkg.resolutions || {},
|
128
|
-
pnpm: pkg.pnpm || {}
|
129
|
-
},
|
130
|
-
{ spaces: 2 }
|
131
|
-
);
|
132
|
-
const manager = yield (0, import_utils.getPackageManager)(appDirectory);
|
133
|
-
const lockfile = import_constants.LOCK_FILE[manager];
|
134
|
-
(0, import_utils2.copyfile)(distDirectory, appDirectory, [lockfile]);
|
135
|
-
import_utils.fs.writeFileSync(
|
136
|
-
import_path.default.join(distDirectory, import_constants.WRANGLER_FILE),
|
137
|
-
`name = "${pkg.name}"
|
138
|
-
main = "${import_path.default.join(import_constants.WORKER_SERVER, import_constants.WORKER_SERVER_ENTRY)}"
|
139
|
-
compatibility_date = "${new Date().toISOString().substring(0, 10)}"
|
140
|
-
`
|
141
|
-
);
|
142
|
-
});
|
143
|
-
}
|
144
|
-
};
|
145
|
-
}
|
146
|
-
});
|
147
|
-
// Annotate the CommonJS export names for ESM import in node:
|
148
|
-
0 && (module.exports = {});
|
package/dist/js/node/utils.js
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
var __create = Object.create;
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
-
var __export = (target, all) => {
|
8
|
-
for (var name in all)
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
10
|
-
};
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
13
|
-
for (let key of __getOwnPropNames(from))
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
|
-
}
|
17
|
-
return to;
|
18
|
-
};
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
21
|
-
mod
|
22
|
-
));
|
23
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
24
|
-
var utils_exports = {};
|
25
|
-
__export(utils_exports, {
|
26
|
-
copyfile: () => copyfile
|
27
|
-
});
|
28
|
-
module.exports = __toCommonJS(utils_exports);
|
29
|
-
var import_path = __toESM(require("path"));
|
30
|
-
var import_utils = require("@modern-js/utils");
|
31
|
-
const copyfile = (target, source, fl) => {
|
32
|
-
fl.forEach((ff) => {
|
33
|
-
if (!ff) {
|
34
|
-
return;
|
35
|
-
}
|
36
|
-
if (typeof ff === "string") {
|
37
|
-
cpfile(target, source, ff);
|
38
|
-
return;
|
39
|
-
}
|
40
|
-
const sourceIncludeFiles = import_utils.fs.readdirSync(source);
|
41
|
-
for (const filename of sourceIncludeFiles) {
|
42
|
-
if (ff.test(filename)) {
|
43
|
-
cpfile(target, source, filename);
|
44
|
-
}
|
45
|
-
}
|
46
|
-
});
|
47
|
-
function cpfile(target2, source2, filename) {
|
48
|
-
const filepath = import_path.default.join(source2, filename);
|
49
|
-
if (!import_utils.fs.existsSync(filepath)) {
|
50
|
-
return;
|
51
|
-
}
|
52
|
-
const targetPath = import_path.default.join(target2, filename);
|
53
|
-
import_utils.fs.copySync(filepath, targetPath);
|
54
|
-
}
|
55
|
-
};
|
56
|
-
// Annotate the CommonJS export names for ESM import in node:
|
57
|
-
0 && (module.exports = {
|
58
|
-
copyfile
|
59
|
-
});
|
@@ -1,4 +0,0 @@
|
|
1
|
-
var worker = function() {
|
2
|
-
return '\n// work entry code\nimport { createHandler, handleUrl } from "@modern-js/prod-server/worker";\nimport loadableStats from "../loadable-stats.json";\nimport routeManifest from "../routes-manifest.json";\nimport { manifest } from "./manifest";\nasync function handleRequest(request) {\n const context = {\n request: {\n ...request,\n url: request.url,\n },\n url: handleUrl(request.url),\n body: null,\n loadableStats,\n routeManifest,\n };\n const handler = createHandler(manifest);\n await handler(context);\n return new Response(context.body, {\n headers: {\n \'content-type\': \'text/html;charset=UTF-8\',\n },\n });\n}\n\naddEventListener("fetch", (event) => {\n event.respondWith(handleRequest(event.request));\n});\n';
|
3
|
-
};
|
4
|
-
export { worker };
|
@@ -1,11 +0,0 @@
|
|
1
|
-
var WORKER_SERVER = "worker-server";
|
2
|
-
var WORKER_SERVER_ENTRY = "index.js";
|
3
|
-
var MANIFEST_FILE = "manifest.js";
|
4
|
-
var PKG_FILE = "package.json";
|
5
|
-
var LOCK_FILE = {
|
6
|
-
yarn: "yarn.lock",
|
7
|
-
npm: "package-lock.json",
|
8
|
-
pnpm: "pnpm-lock.yaml"
|
9
|
-
};
|
10
|
-
var WRANGLER_FILE = "wrangler.toml";
|
11
|
-
export { LOCK_FILE, MANIFEST_FILE, PKG_FILE, WORKER_SERVER, WORKER_SERVER_ENTRY, WRANGLER_FILE };
|
@@ -1,225 +0,0 @@
|
|
1
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
2
|
-
try {
|
3
|
-
var info = gen[key](arg);
|
4
|
-
var value = info.value;
|
5
|
-
} catch (error) {
|
6
|
-
reject(error);
|
7
|
-
return;
|
8
|
-
}
|
9
|
-
if (info.done) {
|
10
|
-
resolve(value);
|
11
|
-
} else {
|
12
|
-
Promise.resolve(value).then(_next, _throw);
|
13
|
-
}
|
14
|
-
}
|
15
|
-
function _asyncToGenerator(fn) {
|
16
|
-
return function() {
|
17
|
-
var self = this, args = arguments;
|
18
|
-
return new Promise(function(resolve, reject) {
|
19
|
-
var gen = fn.apply(self, args);
|
20
|
-
function _next(value) {
|
21
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
22
|
-
}
|
23
|
-
function _throw(err) {
|
24
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
25
|
-
}
|
26
|
-
_next(undefined);
|
27
|
-
});
|
28
|
-
};
|
29
|
-
}
|
30
|
-
var __generator = this && this.__generator || function(thisArg, body) {
|
31
|
-
var f, y, t, g, _ = {
|
32
|
-
label: 0,
|
33
|
-
sent: function() {
|
34
|
-
if (t[0] & 1) throw t[1];
|
35
|
-
return t[1];
|
36
|
-
},
|
37
|
-
trys: [],
|
38
|
-
ops: []
|
39
|
-
};
|
40
|
-
return g = {
|
41
|
-
next: verb(0),
|
42
|
-
"throw": verb(1),
|
43
|
-
"return": verb(2)
|
44
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
45
|
-
return this;
|
46
|
-
}), g;
|
47
|
-
function verb(n) {
|
48
|
-
return function(v) {
|
49
|
-
return step([
|
50
|
-
n,
|
51
|
-
v
|
52
|
-
]);
|
53
|
-
};
|
54
|
-
}
|
55
|
-
function step(op) {
|
56
|
-
if (f) throw new TypeError("Generator is already executing.");
|
57
|
-
while(_)try {
|
58
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
59
|
-
if (y = 0, t) op = [
|
60
|
-
op[0] & 2,
|
61
|
-
t.value
|
62
|
-
];
|
63
|
-
switch(op[0]){
|
64
|
-
case 0:
|
65
|
-
case 1:
|
66
|
-
t = op;
|
67
|
-
break;
|
68
|
-
case 4:
|
69
|
-
_.label++;
|
70
|
-
return {
|
71
|
-
value: op[1],
|
72
|
-
done: false
|
73
|
-
};
|
74
|
-
case 5:
|
75
|
-
_.label++;
|
76
|
-
y = op[1];
|
77
|
-
op = [
|
78
|
-
0
|
79
|
-
];
|
80
|
-
continue;
|
81
|
-
case 7:
|
82
|
-
op = _.ops.pop();
|
83
|
-
_.trys.pop();
|
84
|
-
continue;
|
85
|
-
default:
|
86
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
87
|
-
_ = 0;
|
88
|
-
continue;
|
89
|
-
}
|
90
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
91
|
-
_.label = op[1];
|
92
|
-
break;
|
93
|
-
}
|
94
|
-
if (op[0] === 6 && _.label < t[1]) {
|
95
|
-
_.label = t[1];
|
96
|
-
t = op;
|
97
|
-
break;
|
98
|
-
}
|
99
|
-
if (t && _.label < t[2]) {
|
100
|
-
_.label = t[2];
|
101
|
-
_.ops.push(op);
|
102
|
-
break;
|
103
|
-
}
|
104
|
-
if (t[2]) _.ops.pop();
|
105
|
-
_.trys.pop();
|
106
|
-
continue;
|
107
|
-
}
|
108
|
-
op = body.call(thisArg, _);
|
109
|
-
} catch (e) {
|
110
|
-
op = [
|
111
|
-
6,
|
112
|
-
e
|
113
|
-
];
|
114
|
-
y = 0;
|
115
|
-
} finally{
|
116
|
-
f = t = 0;
|
117
|
-
}
|
118
|
-
if (op[0] & 5) throw op[1];
|
119
|
-
return {
|
120
|
-
value: op[0] ? op[1] : void 0,
|
121
|
-
done: true
|
122
|
-
};
|
123
|
-
}
|
124
|
-
};
|
125
|
-
import path from "path";
|
126
|
-
import { fs, getPackageManager, isServiceWorker, ROUTE_SPEC_FILE } from "@modern-js/utils";
|
127
|
-
import { LOCK_FILE, MANIFEST_FILE, PKG_FILE, WORKER_SERVER, WORKER_SERVER_ENTRY, WRANGLER_FILE } from "./constants";
|
128
|
-
import { worker } from "./code";
|
129
|
-
import { copyfile } from "./utils";
|
130
|
-
var src_default = function() {
|
131
|
-
return {
|
132
|
-
name: "@modern-js/plugin-worker",
|
133
|
-
setup: function(ctx) {
|
134
|
-
return {
|
135
|
-
config: function config() {
|
136
|
-
return _asyncToGenerator(function() {
|
137
|
-
return __generator(this, function(_state) {
|
138
|
-
return [
|
139
|
-
2,
|
140
|
-
{
|
141
|
-
output: {
|
142
|
-
disableNodePolyfill: false
|
143
|
-
}
|
144
|
-
}
|
145
|
-
];
|
146
|
-
});
|
147
|
-
})();
|
148
|
-
},
|
149
|
-
beforeDeploy: function beforeDeploy() {
|
150
|
-
return _asyncToGenerator(function() {
|
151
|
-
var _ctx_useAppContext, appDirectory, distDirectory, configContext, workServerDir, routeJSON, routes, importStr, pageStr, routeArr, manifest, pkg, manager, lockfile;
|
152
|
-
return __generator(this, function(_state) {
|
153
|
-
switch(_state.label){
|
154
|
-
case 0:
|
155
|
-
_ctx_useAppContext = ctx.useAppContext(), appDirectory = _ctx_useAppContext.appDirectory, distDirectory = _ctx_useAppContext.distDirectory;
|
156
|
-
configContext = ctx.useResolvedConfigContext();
|
157
|
-
if (!isServiceWorker(configContext)) {
|
158
|
-
return [
|
159
|
-
2
|
160
|
-
];
|
161
|
-
}
|
162
|
-
workServerDir = path.join(distDirectory, WORKER_SERVER);
|
163
|
-
fs.removeSync(workServerDir);
|
164
|
-
fs.mkdirSync(workServerDir);
|
165
|
-
fs.writeFileSync(path.join(workServerDir, WORKER_SERVER_ENTRY), worker());
|
166
|
-
routeJSON = path.join(distDirectory, ROUTE_SPEC_FILE);
|
167
|
-
routes = fs.readJSONSync(routeJSON).routes;
|
168
|
-
importStr = "";
|
169
|
-
pageStr = "";
|
170
|
-
routeArr = [];
|
171
|
-
routes.forEach(function(route) {
|
172
|
-
if (route.isSSR) {
|
173
|
-
importStr += "import { serverRender as ".concat(route.entryName, 'ServerRender } from "../').concat(route.worker, '";\n');
|
174
|
-
}
|
175
|
-
importStr += "import ".concat(route.entryName, 'template from "../').concat(route.entryPath, '";\n');
|
176
|
-
pageStr += '"'.concat(route.urlPath, '": {\n entryName: "').concat(route.entryName, '",\n template: ').concat(route.entryName, "template,\n serverRender: ").concat(route.isSSR ? "".concat(route.entryName, "ServerRender") : void 0, ",\n },");
|
177
|
-
routeArr.push({
|
178
|
-
entryName: route.entryName,
|
179
|
-
isSSR: route.isSSR,
|
180
|
-
urlPath: route.urlPath
|
181
|
-
});
|
182
|
-
});
|
183
|
-
manifest = "\n".concat(importStr, "\n\nexport const manifest = {\n pages: {\n ").concat(pageStr, "\n },\n routes: ").concat(JSON.stringify(routeArr, null, " "), "\n}\n ");
|
184
|
-
fs.writeFileSync(path.join(workServerDir, MANIFEST_FILE), manifest);
|
185
|
-
pkg = fs.readJSONSync(path.join(appDirectory, PKG_FILE));
|
186
|
-
return [
|
187
|
-
4,
|
188
|
-
fs.writeJSON(path.join(distDirectory, PKG_FILE), {
|
189
|
-
name: pkg.name,
|
190
|
-
version: pkg.version,
|
191
|
-
dependencies: {
|
192
|
-
"@modern-js/prod-server": "0.0.0-next-20230209112307",
|
193
|
-
wrangler: "^2.9.0"
|
194
|
-
},
|
195
|
-
resolutions: pkg.resolutions || {},
|
196
|
-
pnpm: pkg.pnpm || {}
|
197
|
-
}, {
|
198
|
-
spaces: 2
|
199
|
-
})
|
200
|
-
];
|
201
|
-
case 1:
|
202
|
-
_state.sent();
|
203
|
-
return [
|
204
|
-
4,
|
205
|
-
getPackageManager(appDirectory)
|
206
|
-
];
|
207
|
-
case 2:
|
208
|
-
manager = _state.sent();
|
209
|
-
lockfile = LOCK_FILE[manager];
|
210
|
-
copyfile(distDirectory, appDirectory, [
|
211
|
-
lockfile
|
212
|
-
]);
|
213
|
-
fs.writeFileSync(path.join(distDirectory, WRANGLER_FILE), 'name = "'.concat(pkg.name, '"\nmain = "').concat(path.join(WORKER_SERVER, WORKER_SERVER_ENTRY), '"\ncompatibility_date = "').concat(new Date().toISOString().substring(0, 10), '"\n '));
|
214
|
-
return [
|
215
|
-
2
|
216
|
-
];
|
217
|
-
}
|
218
|
-
});
|
219
|
-
})();
|
220
|
-
}
|
221
|
-
};
|
222
|
-
}
|
223
|
-
};
|
224
|
-
};
|
225
|
-
export { src_default as default };
|
@@ -1,45 +0,0 @@
|
|
1
|
-
import path from "path";
|
2
|
-
import { fs } from "@modern-js/utils";
|
3
|
-
var copyfile = function(target, source, fl) {
|
4
|
-
var cpfile = function cpfile(target2, source2, filename) {
|
5
|
-
var filepath = path.join(source2, filename);
|
6
|
-
if (!fs.existsSync(filepath)) {
|
7
|
-
return;
|
8
|
-
}
|
9
|
-
var targetPath = path.join(target2, filename);
|
10
|
-
fs.copySync(filepath, targetPath);
|
11
|
-
};
|
12
|
-
fl.forEach(function(ff) {
|
13
|
-
if (!ff) {
|
14
|
-
return;
|
15
|
-
}
|
16
|
-
if (typeof ff === "string") {
|
17
|
-
cpfile(target, source, ff);
|
18
|
-
return;
|
19
|
-
}
|
20
|
-
var sourceIncludeFiles = fs.readdirSync(source);
|
21
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
22
|
-
try {
|
23
|
-
for(var _iterator = sourceIncludeFiles[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
24
|
-
var filename = _step.value;
|
25
|
-
if (ff.test(filename)) {
|
26
|
-
cpfile(target, source, filename);
|
27
|
-
}
|
28
|
-
}
|
29
|
-
} catch (err) {
|
30
|
-
_didIteratorError = true;
|
31
|
-
_iteratorError = err;
|
32
|
-
} finally{
|
33
|
-
try {
|
34
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
35
|
-
_iterator.return();
|
36
|
-
}
|
37
|
-
} finally{
|
38
|
-
if (_didIteratorError) {
|
39
|
-
throw _iteratorError;
|
40
|
-
}
|
41
|
-
}
|
42
|
-
}
|
43
|
-
});
|
44
|
-
};
|
45
|
-
export { copyfile };
|
package/dist/types/utils.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export declare const copyfile: (target: string, source: string, fl: (string | RegExp)[]) => void;
|
File without changes
|
File without changes
|