@ray-js/builder-mp 1.3.0-beta.2-beta-2 → 1.3.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/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
- let compileOptions = Object.assign({}, defaultCompileOptions, api.config, options);
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 = compileOptions = Object.assign({}, compileOptions, { output: outputPath });
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, outputPath.underline);
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
- const workerBuild = new build_worker_1.default(compileOptions, compiler);
63
- workerBuild.run();
41
+ new build_worker_1.default(options, compiler);
64
42
  if (target === 'thing') {
65
- const rjsBuild = new build_rjs_1.default(compileOptions, compiler);
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,7 @@ class RjsBuild {
21
21
  this.options = options;
22
22
  this.parent = parent;
23
23
  this.initRjsBuilder();
24
+ this.run();
24
25
  }
25
26
  createWebpackConfig() {
26
27
  const { cwd, output, mini, target } = this.options;
@@ -136,19 +137,21 @@ class RjsBuild {
136
137
  }
137
138
  run() {
138
139
  const cb = this.runOrWatch();
139
- if (this.options.watch) {
140
- if (!this.watcher) {
141
- this.watcher = this.compiler.watch({}, cb);
140
+ this.parent.hooks.afterCompile.tap(LOG_PREFIX_RJS, () => {
141
+ if (this.options.watch) {
142
+ if (!this.watcher) {
143
+ this.watcher = this.compiler.watch({}, cb);
144
+ }
145
+ else {
146
+ this.watcher.close(() => {
147
+ this.watcher = this.compiler.watch({}, cb);
148
+ });
149
+ }
142
150
  }
143
151
  else {
144
- this.watcher.close(() => {
145
- this.watcher = this.compiler.watch({}, cb);
146
- });
152
+ this.compiler.run(cb);
147
153
  }
148
- }
149
- else {
150
- this.compiler.run(cb);
151
- }
154
+ });
152
155
  return this.compiler;
153
156
  }
154
157
  }
@@ -21,6 +21,7 @@ class WorkerBuild {
21
21
  this.options = options;
22
22
  this.parent = parent;
23
23
  this.initWorkerBuilder();
24
+ this.run();
24
25
  }
25
26
  createWebpackConfig() {
26
27
  const { cwd, output, mini, target } = this.options;
@@ -166,7 +167,9 @@ class WorkerBuild {
166
167
  });
167
168
  }
168
169
  else {
169
- this.compiler.run(cb);
170
+ this.parent.hooks.afterCompile.tap(LOG_PREFIX_WORKER, () => {
171
+ this.compiler.run(cb);
172
+ });
170
173
  }
171
174
  return this.compiler;
172
175
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/builder-mp",
3
- "version": "1.3.0-beta.2-beta-2",
3
+ "version": "1.3.0",
4
4
  "description": "Ray builder for mini program",
5
5
  "keywords": [
6
6
  "ray"
@@ -21,17 +21,19 @@
21
21
  "test": "jest"
22
22
  },
23
23
  "dependencies": {
24
+ "@babel/plugin-proposal-private-methods": "^7.18.6",
25
+ "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
24
26
  "@babel/template": "^7.16.0",
25
27
  "@babel/traverse": "^7.16.3",
26
28
  "@babel/types": "^7.16.0",
27
- "@ray-core/babel-preset-remax": "^0.2.6",
28
- "@ray-core/build-store": "^0.2.6",
29
- "@ray-core/cli": "^0.2.6",
30
- "@ray-core/ray": "^0.2.6",
31
- "@ray-js/adapter": "^1.3.0-beta.2-beta-2",
29
+ "@ray-core/babel-preset-remax": "^0.3.0",
30
+ "@ray-core/build-store": "^0.3.0",
31
+ "@ray-core/cli": "^0.3.0",
32
+ "@ray-core/ray": "^0.3.0",
33
+ "@ray-js/adapter": "^1.3.0",
32
34
  "@ray-js/rjs-for-wechat": "^0.0.3",
33
- "@ray-js/shared": "^1.3.0-beta.2-beta-2",
34
- "@ray-js/types": "^1.3.0-beta.2-beta-2",
35
+ "@ray-js/shared": "^1.3.0",
36
+ "@ray-js/types": "^1.3.0",
35
37
  "babel-loader": "^8.2.3",
36
38
  "babel-plugin-minify-dead-code-elimination": "^0.5.1",
37
39
  "babel-plugin-transform-prune-unused-imports": "^1.0.1",
@@ -48,7 +50,7 @@
48
50
  "webpack-virtual-modules": "^0.4.4"
49
51
  },
50
52
  "devDependencies": {
51
- "@ray-core/types": "^0.2.6",
53
+ "@ray-core/types": "^0.3.0",
52
54
  "@types/jest": "^27.0.2",
53
55
  "@types/node": "^16.9.1",
54
56
  "babel-plugin-tester": "^10.1.0",
@@ -62,6 +64,6 @@
62
64
  "email": "tuyafe@tuya.com"
63
65
  }
64
66
  ],
65
- "gitHead": "067ce2e382196cd995ebc4774fc5e977ac21115c",
67
+ "gitHead": "f7f96c375a429a2fa94452b0a9af3f841572921a",
66
68
  "repository": {}
67
69
  }