@tuya-sat/micro-script 3.0.0-beta.8 → 3.0.0-beta.9

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.
@@ -23,9 +23,9 @@ const css_minimizer_webpack_plugin_1 = __importDefault(require("css-minimizer-we
23
23
  const micro_dev_loader_1 = require("@tuya-sat/micro-dev-loader");
24
24
  const path_1 = __importDefault(require("path"));
25
25
  const index_1 = require("@tuya-sat/micro-dev-loader/dist/less/utils/index");
26
- const micro_utils_1 = require("@tuya-sat/micro-utils");
27
26
  const paths_1 = __importDefault(require("./paths"));
28
27
  const locales_1 = __importDefault(require("@tuya-sat/micro-dev-loader/dist/plugins/locales"));
28
+ const utils_1 = require("../utils");
29
29
  const toArray = (value) => {
30
30
  return Array.isArray(value) ? value : [value];
31
31
  };
@@ -40,11 +40,10 @@ const validateMicroTheme = () => {
40
40
  exports.validateMicroTheme = validateMicroTheme;
41
41
  function getCommonConfig({ isDev, isBuild, }) {
42
42
  const { name: packageName } = require(paths_1.default.appPkg);
43
- const { annotations } = (0, micro_utils_1.parseManifest)();
44
43
  const devMicroTheme = (0, exports.validateMicroTheme)();
45
44
  const enableThemeCompile = isDev
46
45
  ? !!devMicroTheme
47
- : annotations['sdf.feat:colorTheme'];
46
+ : (0, utils_1.getAnnotations)()['sdf.feat:colorTheme'];
48
47
  //获取style处理的loader
49
48
  const getStyleLoaders = (extraLoader = []) => {
50
49
  extraLoader = toArray(extraLoader);
@@ -107,7 +106,7 @@ function getCommonConfig({ isDev, isBuild, }) {
107
106
  ? enableThemeCompile
108
107
  ? (0, index_1.getLessOptions)(devMicroTheme)
109
108
  : {}
110
- : annotations['sdf.feat:colorTheme']
109
+ : (0, utils_1.getAnnotations)()['sdf.feat:colorTheme']
111
110
  ? (0, index_1.getLessOptions)(index_1.LIGHT_THEME)
112
111
  : {})), { javascriptEnabled: true }),
113
112
  },
@@ -189,7 +188,7 @@ function getCommonConfig({ isDev, isBuild, }) {
189
188
  };
190
189
  return baseConfig;
191
190
  }
192
- if (isBuild && multiApps && multiApps.length > 0) {
191
+ if (multiApps && multiApps.length > 0) {
193
192
  multiApps.forEach((app) => {
194
193
  multiAppsWebpackConfig.entry[app.name] = `${path_1.default.join(process.cwd(), app.dir)}/index.tsx`;
195
194
  multiAppsWebpackConfig.plugins.push(new html_webpack_plugin_1.default({
@@ -6,5 +6,5 @@ export interface BaseParams {
6
6
  export interface WebpackCombineFunction {
7
7
  (arg0: Configuration, arg1: BaseParams): Configuration;
8
8
  }
9
- declare const _default: () => {};
9
+ declare const _default: () => Configuration;
10
10
  export default _default;
@@ -7,47 +7,19 @@ const webpack_merge_1 = require("webpack-merge");
7
7
  const paths_1 = __importDefault(require("./paths"));
8
8
  const framework_1 = __importDefault(require("../framework"));
9
9
  const webpack_common_1 = __importDefault(require("./webpack.common"));
10
- const micro_utils_1 = require("@tuya-sat/micro-utils");
10
+ const utils_1 = require("../utils");
11
11
  exports.default = () => {
12
12
  const isBuild = process.env.NODE_ENV === 'production';
13
13
  const isDev = process.env.NODE_ENV === 'development';
14
- const { annotations: { ['sdf.cli:microFramework']: currentFramework }, } = (0, micro_utils_1.parseManifest)();
15
14
  //框架的webpack配置
16
15
  const frameworkConfig = (0, framework_1.default)({
17
- currentFramework,
16
+ currentFramework: (0, utils_1.getAnnotations)()['sdf.cli:microFramework'],
18
17
  isDev,
19
18
  isBuild,
20
19
  });
21
20
  //公用的webpack配置
22
21
  const commonConfig = (0, webpack_common_1.default)({ isDev, isBuild });
23
- let baseConfig = {};
24
- // const { multiApps } = require(paths.microConfig);
25
- // console.log('multiApps', multiApps, process.cwd());
26
- // if (isBuild && multiApps && multiApps.length > 0) {
27
- // const multiAppsWebpackConfig: any = {
28
- // plugins: [],
29
- // entry: {},
30
- // };
31
- // multiApps.forEach((app: IMicroApp) => {
32
- // multiAppsWebpackConfig.entry[app.name] = `${path.join(
33
- // process.cwd(),
34
- // app.dir
35
- // )}/index.tsx`;
36
- // multiAppsWebpackConfig.plugins.push(
37
- // new HtmlWebpackPlugin({
38
- // inject: true,
39
- // filename: `${app.name}.html`,
40
- // template: paths.spaHtml,
41
- // chunks: [app.name],
42
- // })
43
- // );
44
- // });
45
- // console.log('multiAppsWebpackConfig', multiAppsWebpackConfig);
46
- // baseConfig = merge(frameworkConfig, commonConfig, multiAppsWebpackConfig);
47
- // } else {
48
- // baseConfig = merge(frameworkConfig, commonConfig);
49
- // }
50
- baseConfig = (0, webpack_merge_1.merge)(frameworkConfig, commonConfig);
22
+ const baseConfig = (0, webpack_merge_1.merge)(frameworkConfig, commonConfig);
51
23
  //额外的webpack结合function
52
24
  const webpackCombineFunction = require(paths_1.default.microConfig).webpack;
53
25
  if (webpackCombineFunction && typeof webpackCombineFunction === 'function') {
@@ -117,7 +117,7 @@ function consturctApp(manifest, oem_micro_app_id, baseUrl, lang, port, code) {
117
117
  micro_app_name: code ? `${code}-dev` : `${packageInfo.name}-dev`,
118
118
  micro_app_version: '0.0.0-x',
119
119
  oem_micro_app_id,
120
- resource: `http://localhost:${port}`,
120
+ resource: `http://localhost:${port}/${code || 'index'}.html`,
121
121
  schema: null,
122
122
  universal_id: manifest.universalId,
123
123
  isAuth: true,
@@ -0,0 +1 @@
1
+ export declare const getAnnotations: () => any;
@@ -0,0 +1,43 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.getAnnotations = void 0;
30
+ const micro_utils_1 = require("@tuya-sat/micro-utils");
31
+ const path = __importStar(require("path"));
32
+ const paths_1 = __importDefault(require("../config/paths"));
33
+ const fs_extra_1 = __importDefault(require("fs-extra"));
34
+ const getAnnotations = () => {
35
+ const { multiApps } = require(paths_1.default.microConfig);
36
+ if (multiApps && multiApps.length > 0) {
37
+ return fs_extra_1.default.readJSONSync(path.join(process.cwd(), multiApps[0].dir, 'manifest.json')).annotations;
38
+ }
39
+ else {
40
+ return (0, micro_utils_1.parseManifest)().annotations;
41
+ }
42
+ };
43
+ exports.getAnnotations = getAnnotations;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-sat/micro-script",
3
- "version": "3.0.0-beta.8",
3
+ "version": "3.0.0-beta.9",
4
4
  "bin": "./dist/bin/cli.js",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
@@ -20,9 +20,9 @@
20
20
  "@babel/preset-react": "7.16.7",
21
21
  "@babel/preset-typescript": "7.16.7",
22
22
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.4",
23
- "@tuya-sat/micro-dev-loader": "3.0.0-beta.8",
24
- "@tuya-sat/micro-dev-proxy": "3.0.0-beta.8",
25
- "@tuya-sat/micro-utils": "3.0.0-beta.8",
23
+ "@tuya-sat/micro-dev-loader": "3.0.0-beta.9",
24
+ "@tuya-sat/micro-dev-proxy": "3.0.0-beta.9",
25
+ "@tuya-sat/micro-utils": "3.0.0-beta.9",
26
26
  "babel-loader": "8.2.4",
27
27
  "babel-plugin-import": "1.13.3",
28
28
  "chalk": "4.1.2",