@ray-js/builder-mp 0.20.0-beta.0 → 0.20.0-beta.2
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/lib/build.js +6 -13
- package/lib/plugins/rjs.d.ts +6 -0
- package/lib/plugins/rjs.js +11 -0
- package/lib/ray-core.d.ts +1 -2
- package/lib/ray-core.js +8 -8
- package/package.json +10 -10
- /package/lib/{build.rjs.d.ts → builder.rjs.d.ts} +0 -0
- /package/lib/{build.rjs.js → builder.rjs.js} +0 -0
package/lib/build.js
CHANGED
@@ -17,7 +17,7 @@ const shared_1 = require("@ray-js/shared");
|
|
17
17
|
const legacyExport_1 = require("@ray-core/cli/lib/legacyExport");
|
18
18
|
const package_json_1 = __importDefault(require("@ray-core/cli/package.json"));
|
19
19
|
const builder_1 = require("./builder");
|
20
|
-
const
|
20
|
+
const builder_rjs_1 = __importDefault(require("./builder.rjs"));
|
21
21
|
const ray_core_1 = require("./ray-core");
|
22
22
|
colors_1.default.enable();
|
23
23
|
const LOG_PREFIX = 'builder-mp';
|
@@ -32,26 +32,19 @@ const defaultCompileOptions = {
|
|
32
32
|
devtools: false,
|
33
33
|
debug: false,
|
34
34
|
output: 'dist',
|
35
|
-
blended: false,
|
36
35
|
};
|
37
36
|
function build(options, context) {
|
38
37
|
return __awaiter(this, void 0, void 0, function* () {
|
39
38
|
const { api } = context;
|
40
|
-
|
41
|
-
|
42
|
-
o[k] = api.config[k];
|
43
|
-
}
|
44
|
-
return o;
|
45
|
-
}, {});
|
46
|
-
let compileOptions = Object.assign({}, defaultCompileOptions, cfgFromRayConfigFile, options);
|
47
|
-
const { cwd, target, output, devtools } = compileOptions;
|
39
|
+
let compileOptions = Object.assign({}, defaultCompileOptions, api.config, options);
|
40
|
+
const { cwd, target, output, devtools, onTargetDir } = compileOptions;
|
48
41
|
/**
|
49
42
|
* 又是历史原因
|
50
43
|
* 因老项目生成的产物目录是tuya,所以就干脆是tuya,不然会出现既 tuya 又 thing 的目录
|
51
44
|
* 将开发整懵逼
|
52
45
|
*/
|
53
46
|
const dist = target === 'thing' ? 'tuya' : target;
|
54
|
-
const outputPath = (0, shared_1.resolvePath)([output, dist], { cwd });
|
47
|
+
const outputPath = (0, shared_1.resolvePath)(typeof onTargetDir === 'function' ? [onTargetDir(output, dist)] : [output, dist], { cwd });
|
55
48
|
// 上下文共享 options
|
56
49
|
builder_1.builder.api = api;
|
57
50
|
builder_1.builder.options = compileOptions = Object.assign({}, compileOptions, { output: outputPath });
|
@@ -62,11 +55,11 @@ function build(options, context) {
|
|
62
55
|
if (devtools) {
|
63
56
|
shared_1.log.info(LOG_PREFIX, '开启 devtools 开发者工具环境变量'.yellow, devtools);
|
64
57
|
}
|
65
|
-
const rayCoreOpts = (0, ray_core_1.getRayCoreOptions)(
|
58
|
+
const rayCoreOpts = (0, ray_core_1.getRayCoreOptions)();
|
66
59
|
const rayApi = new ray_core_1.RayAPI(rayCoreOpts);
|
67
60
|
// 编译除rjs模块外的小程序模块
|
68
61
|
const compiler = (0, legacyExport_1.buildMini)(rayApi, rayCoreOpts);
|
69
|
-
|
62
|
+
builder_rjs_1.default.init(compiler, compileOptions); // TODO rjs 可用动态虚拟模块实现单webpack编译
|
70
63
|
return compiler;
|
71
64
|
});
|
72
65
|
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const builder_rjs_1 = __importDefault(require("../builder.rjs"));
|
7
|
+
exports.default = {
|
8
|
+
configWebpack({ config }) {
|
9
|
+
builder_rjs_1.default.config(config);
|
10
|
+
},
|
11
|
+
};
|
package/lib/ray-core.d.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
import type { Options, Platform } from '@ray-core/types';
|
2
2
|
import RayCoreAPI from '@ray-core/cli/lib/API';
|
3
|
-
|
4
|
-
export declare function getRayCoreOptions(rjsBuilder: RjsBuilder): Options;
|
3
|
+
export declare function getRayCoreOptions(): Options;
|
5
4
|
export declare class RayAPI extends RayCoreAPI {
|
6
5
|
constructor(opts: Options);
|
7
6
|
registerAdapterPlugins(target: Platform): void;
|
package/lib/ray-core.js
CHANGED
@@ -19,10 +19,12 @@ const path_1 = __importDefault(require("path"));
|
|
19
19
|
const legacyExport_1 = require("@ray-core/cli/lib/legacyExport");
|
20
20
|
const API_1 = __importDefault(require("@ray-core/cli/lib/API"));
|
21
21
|
const build_store_1 = __importDefault(require("@ray-core/build-store"));
|
22
|
+
const BlendedApp_1 = __importDefault(require("@ray-core/cli/lib/plugins/BlendedApp"));
|
22
23
|
const resolve_alias_1 = __importDefault(require("./plugins/resolve-alias"));
|
23
24
|
const app_entry_1 = __importDefault(require("./plugins/app-entry"));
|
24
25
|
const less_1 = __importDefault(require("./plugins/less"));
|
25
26
|
const resolve_legacy_1 = __importDefault(require("./plugins/resolve-legacy"));
|
27
|
+
const rjs_1 = __importDefault(require("./plugins/rjs"));
|
26
28
|
const builder_1 = require("./builder");
|
27
29
|
const _a = (0, legacyExport_1.getDefaultOptions)(), { UNSAFE_wechatTemplateDepth } = _a, remaxDefaultOptions = __rest(_a, ["UNSAFE_wechatTemplateDepth"]);
|
28
30
|
const isThing = process.env.PLATFORM === 'thing';
|
@@ -41,17 +43,15 @@ const defaultTemplateDepth = isThing
|
|
41
43
|
'navigation-bar': -1,
|
42
44
|
}
|
43
45
|
: {};
|
44
|
-
const innerPlugins = [resolve_legacy_1.default, app_entry_1.default, less_1.default, resolve_alias_1.default];
|
45
|
-
function getRayCoreOptions(
|
46
|
+
const innerPlugins = [resolve_legacy_1.default, app_entry_1.default, less_1.default, resolve_alias_1.default, rjs_1.default];
|
47
|
+
function getRayCoreOptions() {
|
46
48
|
const { cwd, source, watch, target, mini, analyze, output, blended } = builder_1.builder.options;
|
49
|
+
if (blended) {
|
50
|
+
innerPlugins.push(BlendedApp_1.default);
|
51
|
+
}
|
47
52
|
const api = builder_1.builder.api;
|
48
|
-
const injectWebpackConfigToRjs = {
|
49
|
-
configWebpack({ config }) {
|
50
|
-
rjsBuilder.config(config);
|
51
|
-
},
|
52
|
-
};
|
53
53
|
// @ts-ignore
|
54
|
-
const plugins = innerPlugins.concat(api.plugins
|
54
|
+
const plugins = innerPlugins.concat(api.plugins);
|
55
55
|
const remaxBuildConfig = Object.assign(Object.assign({}, remaxDefaultOptions), { UNSAFE_wechatTemplateDepth: Object.assign(UNSAFE_wechatTemplateDepth, defaultTemplateDepth), compressTemplate: mini, pxToRpx: false, minimize: mini, analyze,
|
56
56
|
cwd, loglevel: 'warn', rootDir: source, target, output: path_1.default.relative(cwd, output), watch,
|
57
57
|
plugins,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ray-js/builder-mp",
|
3
|
-
"version": "0.20.0-beta.
|
3
|
+
"version": "0.20.0-beta.2",
|
4
4
|
"description": "Ray builder for mini program",
|
5
5
|
"keywords": [
|
6
6
|
"ray"
|
@@ -24,14 +24,14 @@
|
|
24
24
|
"@babel/template": "^7.16.0",
|
25
25
|
"@babel/traverse": "^7.16.3",
|
26
26
|
"@babel/types": "^7.16.0",
|
27
|
-
"@ray-core/babel-preset-remax": "^0.2.0-beta.
|
28
|
-
"@ray-core/build-store": "^0.2.0-beta.
|
29
|
-
"@ray-core/cli": "^0.2.0-beta.
|
30
|
-
"@ray-core/ray": "^0.2.0-beta.
|
31
|
-
"@ray-js/adapter": "^0.20.0-beta.
|
27
|
+
"@ray-core/babel-preset-remax": "^0.2.0-beta.7",
|
28
|
+
"@ray-core/build-store": "^0.2.0-beta.7",
|
29
|
+
"@ray-core/cli": "^0.2.0-beta.7",
|
30
|
+
"@ray-core/ray": "^0.2.0-beta.7",
|
31
|
+
"@ray-js/adapter": "^0.20.0-beta.2",
|
32
32
|
"@ray-js/rjs-for-wechat": "^0.0.3",
|
33
|
-
"@ray-js/shared": "^0.20.0-beta.
|
34
|
-
"@ray-js/types": "^0.20.0-beta.
|
33
|
+
"@ray-js/shared": "^0.20.0-beta.2",
|
34
|
+
"@ray-js/types": "^0.20.0-beta.2",
|
35
35
|
"babel-loader": "^8.2.3",
|
36
36
|
"babel-plugin-minify-dead-code-elimination": "^0.5.1",
|
37
37
|
"babel-plugin-transform-prune-unused-imports": "^1.0.1",
|
@@ -48,7 +48,7 @@
|
|
48
48
|
"webpack-virtual-modules": "^0.4.4"
|
49
49
|
},
|
50
50
|
"devDependencies": {
|
51
|
-
"@ray-core/types": "^0.2.0-beta.
|
51
|
+
"@ray-core/types": "^0.2.0-beta.7",
|
52
52
|
"@types/jest": "^27.0.2",
|
53
53
|
"@types/node": "^16.9.1",
|
54
54
|
"babel-plugin-tester": "^10.1.0",
|
@@ -62,6 +62,6 @@
|
|
62
62
|
"email": "tuyafe@tuya.com"
|
63
63
|
}
|
64
64
|
],
|
65
|
-
"gitHead": "
|
65
|
+
"gitHead": "67aa3b9aa0a8113c3965772893bdd76ed3a243bf",
|
66
66
|
"repository": {}
|
67
67
|
}
|
File without changes
|
File without changes
|