@unmagic/vms 0.1.0 → 0.1.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.
|
@@ -19,6 +19,7 @@ import { createRequire } from "node:module";
|
|
|
19
19
|
import chokidar from "chokidar";
|
|
20
20
|
import { getPackageInfo } from "local-pkg";
|
|
21
21
|
import os from "node:os";
|
|
22
|
+
import process$1 from "node:process";
|
|
22
23
|
import { rolldown } from "rolldown";
|
|
23
24
|
import { minify } from "terser";
|
|
24
25
|
import { performance } from "perf_hooks";
|
|
@@ -1007,7 +1008,7 @@ if (!userConfig.wx) throw new Error("请在vms.config.*s中配置完整的wx");
|
|
|
1007
1008
|
process.env.APP_VERSION = userConfig.wx.version;
|
|
1008
1009
|
if (!userConfig.sourceDir) userConfig.sourceDir = "src";
|
|
1009
1010
|
if (!userConfig.outputDir) userConfig.outputDir = "dist";
|
|
1010
|
-
const OUTPUT_DIR = path.resolve(userConfig.outputDir, "
|
|
1011
|
+
const OUTPUT_DIR = path.resolve(userConfig.outputDir, "dev");
|
|
1011
1012
|
const POLYFILL_OUTPUT_DIR = path.resolve(OUTPUT_DIR, "polyfill");
|
|
1012
1013
|
const getComponentMatcher = new ComponentMatcher(userConfig.component);
|
|
1013
1014
|
function findPolyfillDirectory(baseDir) {
|
|
@@ -1687,7 +1688,7 @@ function copyProjectConfigFile() {
|
|
|
1687
1688
|
return fs$1.readJson(path.join(process.cwd(), "project.config.json")).then((config) => {
|
|
1688
1689
|
Reflect.deleteProperty(config, "miniprogramRoot");
|
|
1689
1690
|
Reflect.deleteProperty(config, "srcMiniprogramRoot");
|
|
1690
|
-
config.projectName = config.projectName + "-
|
|
1691
|
+
config.projectName = config.projectName + "-dev";
|
|
1691
1692
|
return fs$1.writeFile(path.join(OUTPUT_DIR, "project.config.json"), JSON.stringify(config, null, 2));
|
|
1692
1693
|
});
|
|
1693
1694
|
}
|
|
@@ -4093,7 +4094,7 @@ function bindingifyBuiltInPlugin(plugin) {
|
|
|
4093
4094
|
* **Basic usage**
|
|
4094
4095
|
* ```js
|
|
4095
4096
|
* replacePlugin({
|
|
4096
|
-
* '
|
|
4097
|
+
* 'process.env.NODE_ENV': JSON.stringify('production'),
|
|
4097
4098
|
* __buildVersion: 15
|
|
4098
4099
|
* })
|
|
4099
4100
|
* ```
|
|
@@ -4101,7 +4102,7 @@ function bindingifyBuiltInPlugin(plugin) {
|
|
|
4101
4102
|
* **With options**
|
|
4102
4103
|
* ```js
|
|
4103
4104
|
* replacePlugin({
|
|
4104
|
-
* '
|
|
4105
|
+
* 'process.env.NODE_ENV': JSON.stringify('production'),
|
|
4105
4106
|
* __buildVersion: 15
|
|
4106
4107
|
* }, {
|
|
4107
4108
|
* preventAssignment: false,
|
|
@@ -4123,7 +4124,7 @@ function replacePlugin(values = {}, options = {}) {
|
|
|
4123
4124
|
}
|
|
4124
4125
|
//#endregion
|
|
4125
4126
|
//#region src/cli.ts
|
|
4126
|
-
const NODE_ENV = "production";
|
|
4127
|
+
const NODE_ENV = process$1.env.NODE_ENV || "production";
|
|
4127
4128
|
let pagePaths = null;
|
|
4128
4129
|
const pageComponentCache = /* @__PURE__ */ new Map();
|
|
4129
4130
|
/**
|
|
@@ -4253,7 +4254,7 @@ async function bundleModule(module, pkg) {
|
|
|
4253
4254
|
await (await rolldown({
|
|
4254
4255
|
input: module,
|
|
4255
4256
|
external: peerDependencies ? Object.keys(peerDependencies) : void 0,
|
|
4256
|
-
plugins: [replacePlugin({ "
|
|
4257
|
+
plugins: [replacePlugin({ "process.env.NODE_ENV": JSON.stringify(NODE_ENV) }, { preventAssignment: true })],
|
|
4257
4258
|
treeshake: true
|
|
4258
4259
|
})).write({
|
|
4259
4260
|
file: `${pkg.replace(sourceDir, OUTPUT_DIR)}/miniprogram_npm/${module}/index.js`,
|
|
@@ -4307,8 +4308,6 @@ async function buildComponentLibrary(name) {
|
|
|
4307
4308
|
if (entry.isDirectory()) await processJsFiles(fullPath);
|
|
4308
4309
|
else if (entry.isFile() && entry.name.endsWith(".js")) jsFiles.push(fullPath);
|
|
4309
4310
|
}
|
|
4310
|
-
const jsConcurrency = Math.min(10, CONCURRENT_LIMIT);
|
|
4311
|
-
console.log(bold(green(` 处理 ${jsFiles.length} 个 JS 文件(并发=${jsConcurrency})...`)));
|
|
4312
4311
|
await batchProcess(jsFiles, async (filePath) => {
|
|
4313
4312
|
try {
|
|
4314
4313
|
const result = await transformFileAsync(filePath, {
|
|
@@ -4326,7 +4325,7 @@ async function buildComponentLibrary(name) {
|
|
|
4326
4325
|
} catch (error) {
|
|
4327
4326
|
console.error(`处理 ${filePath} 失败:`, getErrorMessage(error));
|
|
4328
4327
|
}
|
|
4329
|
-
},
|
|
4328
|
+
}, Math.min(10, CONCURRENT_LIMIT));
|
|
4330
4329
|
};
|
|
4331
4330
|
await processJsFiles(destination);
|
|
4332
4331
|
if (independentPackages.length > 0) await Promise.all(independentPackages.map(async (item) => {
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import dotenv from "dotenv-flow";
|
|
|
2
2
|
//#region src/index.ts
|
|
3
3
|
async function runVMS(options) {
|
|
4
4
|
dotenv.config({ node_env: options.mode });
|
|
5
|
-
const { dev, prod } = await import("./cli-
|
|
5
|
+
const { dev, prod } = await import("./cli-B7IxnuYZ.js");
|
|
6
6
|
if (options.mode === "production") return prod(options);
|
|
7
7
|
else return dev();
|
|
8
8
|
}
|