@ray-js/builder-mp 0.10.0-beta.0 → 0.10.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.
@@ -152,24 +152,13 @@ function ContextAndHoc() {
152
152
  let exportDefaultDeclarationName;
153
153
  return {
154
154
  pre(state) {
155
- isPage = false;
156
155
  exportDefaultDeclarationName = '';
157
156
  entries = Object.keys(builder_1.builder.entry);
158
157
  const sourceDir = (0, slash_1.default)(P.join(builder_1.builder.options.cwd, builder_1.builder.options.source));
159
158
  const filename = (0, slash_1.default)(state.opts.filename);
160
159
  const fileName = P.relative(sourceDir, filename);
161
- const ext = P.extname(fileName);
162
- const entryNames = ['.mini', `.${builder_1.builder.options.target}`, ''].map((x) => fileName.replace(`${x}${ext}`, ''));
163
- for (const p of entryNames) {
164
- if (p.toLowerCase() === 'app')
165
- return;
166
- for (const e of entries) {
167
- if (e === p) {
168
- isPage = true;
169
- return;
170
- }
171
- }
172
- }
160
+ const fileEntryName = fileName.replace(P.extname(fileName), '');
161
+ isPage = fileEntryName.toLowerCase() !== 'app' && entries.some((e) => e === fileEntryName);
173
162
  },
174
163
  visitor: {
175
164
  ExportDefaultDeclaration(path, state) {
package/lib/build.js CHANGED
@@ -32,18 +32,11 @@ 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
- const cfgFromRayConfigFile = Object.keys(defaultCompileOptions).reduce((o, k) => {
41
- if (k in api.config) {
42
- o[k] = api.config[k];
43
- }
44
- return o;
45
- }, {});
46
- let compileOptions = Object.assign({}, defaultCompileOptions, cfgFromRayConfigFile, options);
39
+ let compileOptions = Object.assign({}, defaultCompileOptions, options);
47
40
  const { cwd, target, output, devtools } = compileOptions;
48
41
  /**
49
42
  * 又是历史原因
@@ -1,29 +1,5 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
- const babel = __importStar(require("@babel/core"));
27
3
  // TODO 动态生成app.config.ts文件还是会造成二次编译,待优化
28
4
  // 原有实现方案会造成二次编译,导致编译性能下降
29
5
  // https://registry.code.tuya-inc.top/godzilla/ray-monorepo/-/blob/3bb0c0754881b4bc0ebdb4540f628c941bfb3be8/packages/builder-mp/src/webpack/plugins/AppFrameworkEntry/index.ts
@@ -37,43 +13,11 @@ function configWebpack(context) {
37
13
  if (thePlugin._staticModules) {
38
14
  const file = Object.keys(thePlugin._staticModules).find((name) => /\/?app\./.test(name));
39
15
  const source = thePlugin._staticModules[file];
40
- const content = `
41
- import router from '@ray-js/ray/main';
42
- ${updateCode(source, file)};
43
- function reOverloadNativeAppConstructor(config) {
44
- const app = overloadNativeAppConstructor(config);
45
- return function(opts) {
46
- opts && opts.subPackageRoot && router.setUrlPrefix(opts.subPackageRoot);
47
- return app(opts);
48
- }
49
- }
50
- `;
16
+ const content = `import '@ray-js/ray/main';${source}`;
51
17
  thePlugin._staticModules[file] = content;
52
18
  plugin.set('plugin', thePlugin);
53
19
  }
54
20
  }
55
- function updateCode(code, name) {
56
- const opts = {
57
- plugins: [
58
- function () {
59
- return {
60
- visitor: {
61
- Identifier(path) {
62
- if (path.parent.type === 'CallExpression' &&
63
- path.node.name === 'overloadNativeAppConstructor') {
64
- path.node.name = 'reOverloadNativeAppConstructor';
65
- }
66
- },
67
- },
68
- };
69
- },
70
- ],
71
- sourceFileName: name,
72
- filename: name,
73
- };
74
- const res = babel.transformSync(code, opts);
75
- return res === null || res === void 0 ? void 0 : res.code;
76
- }
77
21
  exports.default = {
78
22
  name: 'app-entry-wrapper',
79
23
  configWebpack,
package/lib/ray-core.js CHANGED
@@ -25,25 +25,22 @@ const less_1 = __importDefault(require("./plugins/less"));
25
25
  const resolve_legacy_1 = __importDefault(require("./plugins/resolve-legacy"));
26
26
  const builder_1 = require("./builder");
27
27
  const _a = (0, legacyExport_1.getDefaultOptions)(), { UNSAFE_wechatTemplateDepth } = _a, remaxDefaultOptions = __rest(_a, ["UNSAFE_wechatTemplateDepth"]);
28
- const isThing = process.env.PLATFORM === 'thing';
29
- const defaultTemplateDepth = isThing
30
- ? {
31
- swiper: 3,
32
- text: 1,
33
- ad: -1,
34
- 'match-media': -1,
35
- 'page-container': -1,
36
- 'share-element': -1,
37
- 'keyboard-accessory': -1,
38
- 'voip-room': -1,
39
- 'ad-custom': -1,
40
- 'page-meta': -1,
41
- 'navigation-bar': -1,
42
- }
43
- : {};
28
+ const defaultTemplateDepth = {
29
+ swiper: 3,
30
+ text: 1,
31
+ ad: -1,
32
+ 'match-media': -1,
33
+ 'page-container': -1,
34
+ 'share-element': -1,
35
+ 'keyboard-accessory': -1,
36
+ 'voip-room': -1,
37
+ 'ad-custom': -1,
38
+ 'page-meta': -1,
39
+ 'navigation-bar': -1,
40
+ };
44
41
  const innerPlugins = [resolve_legacy_1.default, app_entry_1.default, less_1.default, resolve_alias_1.default];
45
42
  function getRayCoreOptions(rjsBuilder) {
46
- const { cwd, source, watch, target, mini, analyze, output, blended } = builder_1.builder.options;
43
+ const { cwd, source, watch, target, mini, analyze, output } = builder_1.builder.options;
47
44
  const api = builder_1.builder.api;
48
45
  const injectWebpackConfigToRjs = {
49
46
  configWebpack({ config }) {
@@ -54,8 +51,7 @@ function getRayCoreOptions(rjsBuilder) {
54
51
  const plugins = innerPlugins.concat(api.plugins, injectWebpackConfigToRjs);
55
52
  const remaxBuildConfig = Object.assign(Object.assign({}, remaxDefaultOptions), { UNSAFE_wechatTemplateDepth: Object.assign(UNSAFE_wechatTemplateDepth, defaultTemplateDepth), compressTemplate: mini, pxToRpx: false, minimize: mini, analyze,
56
53
  cwd, loglevel: 'warn', rootDir: source, target, output: path_1.default.relative(cwd, output), watch,
57
- plugins,
58
- blended });
54
+ plugins });
59
55
  return remaxBuildConfig;
60
56
  }
61
57
  exports.getRayCoreOptions = getRayCoreOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/builder-mp",
3
- "version": "0.10.0-beta.0",
3
+ "version": "0.10.0",
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.2",
28
- "@ray-core/build-store": "^0.2.0-beta.2",
29
- "@ray-core/cli": "^0.2.0-beta.2",
30
- "@ray-core/ray": "^0.2.0-beta.2",
31
- "@ray-js/adapter": "^0.10.0-beta.0",
27
+ "@ray-core/babel-preset-remax": "^0.1.3",
28
+ "@ray-core/build-store": "^0.1.3",
29
+ "@ray-core/cli": "^0.1.3",
30
+ "@ray-core/ray": "^0.1.3",
31
+ "@ray-js/adapter": "^0.10.0",
32
32
  "@ray-js/rjs-for-wechat": "^0.0.3",
33
- "@ray-js/shared": "^0.10.0-beta.0",
34
- "@ray-js/types": "^0.10.0-beta.0",
33
+ "@ray-js/shared": "^0.10.0",
34
+ "@ray-js/types": "^0.10.0",
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.2",
51
+ "@ray-core/types": "^0.1.3",
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": "84f7689f7ab2bb23abf6a7dd48ac0cce03127cb2",
65
+ "gitHead": "38d0bfba4c3216d59bfd0aa2dbce3f4337b22b2e",
66
66
  "repository": {}
67
67
  }