@ray-js/builder-mp 1.3.0-beta.2-beta-2 → 1.3.0-beta.3
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 +5 -30
- package/lib/build.rjs.js +3 -15
- package/lib/build.worker.js +1 -0
- package/package.json +10 -10
package/lib/build.js
CHANGED
@@ -22,50 +22,25 @@ const build_rjs_1 = __importDefault(require("./build.rjs"));
|
|
22
22
|
const build_worker_1 = __importDefault(require("./build.worker"));
|
23
23
|
colors_1.default.enable();
|
24
24
|
const LOG_PREFIX = 'builder-mp';
|
25
|
-
const defaultCompileOptions = {
|
26
|
-
cwd: process.cwd(),
|
27
|
-
source: 'src',
|
28
|
-
mode: 'development',
|
29
|
-
watch: false,
|
30
|
-
target: 'wechat',
|
31
|
-
mini: false,
|
32
|
-
analyze: false,
|
33
|
-
devtools: false,
|
34
|
-
debug: false,
|
35
|
-
output: 'dist',
|
36
|
-
};
|
37
25
|
function build(options, context) {
|
38
26
|
return __awaiter(this, void 0, void 0, function* () {
|
39
27
|
const { api } = context;
|
40
|
-
|
41
|
-
const { cwd, target, output, devtools, onTargetDir } = compileOptions;
|
42
|
-
/**
|
43
|
-
* 又是历史原因
|
44
|
-
* 因老项目生成的产物目录是tuya,所以就干脆是tuya,不然会出现既 tuya 又 thing 的目录
|
45
|
-
* 将开发整懵逼
|
46
|
-
*/
|
47
|
-
const dist = target === 'thing' ? 'tuya' : target;
|
48
|
-
const outputPath = (0, shared_1.resolvePath)(typeof onTargetDir === 'function' ? [onTargetDir(output, dist)] : [output, dist], { cwd });
|
28
|
+
const { cwd, target, output, devtools } = options;
|
49
29
|
// 上下文共享 options
|
50
30
|
builder_1.builder.api = api;
|
51
|
-
builder_1.builder.options =
|
52
|
-
shared_1.log.verbose(LOG_PREFIX, `compileOptions:`, compileOptions);
|
31
|
+
builder_1.builder.options = options;
|
53
32
|
shared_1.log.info(LOG_PREFIX, '@ray-core/cli:'.green, `v${package_json_1.default.version}`);
|
54
33
|
shared_1.log.info(LOG_PREFIX, 'cwd:'.green, cwd.underline);
|
55
|
-
shared_1.log.info(LOG_PREFIX, 'outputDir:'.green,
|
34
|
+
shared_1.log.info(LOG_PREFIX, 'outputDir:'.green, output.underline);
|
56
35
|
if (devtools) {
|
57
36
|
shared_1.log.info(LOG_PREFIX, '开启 devtools 开发者工具环境变量'.yellow, devtools);
|
58
37
|
}
|
59
38
|
const rayCoreOpts = (0, ray_core_1.getRayCoreOptions)();
|
60
39
|
const rayApi = new ray_core_1.RayAPI(rayCoreOpts);
|
61
40
|
const compiler = (0, legacyExport_1.buildMini)(rayApi, rayCoreOpts);
|
62
|
-
|
63
|
-
workerBuild.run();
|
41
|
+
new build_worker_1.default(options, compiler);
|
64
42
|
if (target === 'thing') {
|
65
|
-
|
66
|
-
compiler.hooks.afterCompile.tap(LOG_PREFIX, () => {
|
67
|
-
rjsBuild.run();
|
68
|
-
});
|
43
|
+
new build_rjs_1.default(options, compiler);
|
69
44
|
}
|
70
45
|
return compiler;
|
71
46
|
});
|
package/lib/build.rjs.js
CHANGED
@@ -21,6 +21,9 @@ class RjsBuild {
|
|
21
21
|
this.options = options;
|
22
22
|
this.parent = parent;
|
23
23
|
this.initRjsBuilder();
|
24
|
+
parent.hooks.afterCompile.tap(LOG_PREFIX_RJS, () => {
|
25
|
+
this.run();
|
26
|
+
});
|
24
27
|
}
|
25
28
|
createWebpackConfig() {
|
26
29
|
const { cwd, output, mini, target } = this.options;
|
@@ -46,21 +49,6 @@ class RjsBuild {
|
|
46
49
|
.options({
|
47
50
|
configFile: path_1.default.resolve(__dirname, './babel/configs/babel.config.js'),
|
48
51
|
});
|
49
|
-
config.module
|
50
|
-
.rule('image-sources')
|
51
|
-
.test(/\.(png|jpe?g|gif|svg)$/i)
|
52
|
-
// @ts-ignore
|
53
|
-
.type('asset')
|
54
|
-
.parser({
|
55
|
-
dataUrlCondition: {
|
56
|
-
maxSize: 8 * 1024,
|
57
|
-
},
|
58
|
-
});
|
59
|
-
config.module
|
60
|
-
.rule('font-sources')
|
61
|
-
.test(/\.(ttf|eot|woff|woff2)$/)
|
62
|
-
// @ts-ignore
|
63
|
-
.type('asset/resource');
|
64
52
|
config.output
|
65
53
|
.set('filename', '[name].rjs')
|
66
54
|
.set('libraryTarget', 'commonjs2')
|
package/lib/build.worker.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ray-js/builder-mp",
|
3
|
-
"version": "1.3.0-beta.
|
3
|
+
"version": "1.3.0-beta.3",
|
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.
|
28
|
-
"@ray-core/build-store": "^0.
|
29
|
-
"@ray-core/cli": "^0.
|
30
|
-
"@ray-core/ray": "^0.
|
31
|
-
"@ray-js/adapter": "^1.3.0-beta.
|
27
|
+
"@ray-core/babel-preset-remax": "^0.3.0-beta.4",
|
28
|
+
"@ray-core/build-store": "^0.3.0-beta.4",
|
29
|
+
"@ray-core/cli": "^0.3.0-beta.4",
|
30
|
+
"@ray-core/ray": "^0.3.0-beta.4",
|
31
|
+
"@ray-js/adapter": "^1.3.0-beta.3",
|
32
32
|
"@ray-js/rjs-for-wechat": "^0.0.3",
|
33
|
-
"@ray-js/shared": "^1.3.0-beta.
|
34
|
-
"@ray-js/types": "^1.3.0-beta.
|
33
|
+
"@ray-js/shared": "^1.3.0-beta.3",
|
34
|
+
"@ray-js/types": "^1.3.0-beta.3",
|
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.
|
51
|
+
"@ray-core/types": "^0.3.0-beta.4",
|
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": "be72a5dad6214ebf9c6653df02956374c735c98e",
|
66
66
|
"repository": {}
|
67
67
|
}
|