@ray-js/build-plugin-ray 0.6.21 → 0.6.22-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/index.js CHANGED
@@ -5,29 +5,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const colors_1 = __importDefault(require("colors"));
7
7
  const path_1 = __importDefault(require("path"));
8
- const fs_extra_1 = __importDefault(require("fs-extra"));
9
8
  const shared_1 = require("@ray-js/shared");
9
+ const slash_1 = __importDefault(require("slash"));
10
10
  colors_1.default.enable();
11
- const BUILD_TEMP_DIR = '.ray';
12
- const LOG_PREFIX = `build-plugin-ray`;
11
+ const LOG_PREFIX = `@ray-js/ray => ray`;
13
12
  function PluginRay(api) {
14
- const { options: { cwd }, } = api;
15
- const rayFolder = path_1.default.join(cwd, BUILD_TEMP_DIR);
13
+ const cwd = api.options.cwd;
14
+ let rayMod;
15
+ try {
16
+ const p = (0, slash_1.default)(path_1.default.join(cwd, 'node_modules', '@ray-js/ray'));
17
+ rayMod = require.resolve(p);
18
+ }
19
+ catch (e) {
20
+ rayMod = require.resolve('@ray-js/ray');
21
+ shared_1.log.warn('', `Can't resolve module '@ray-js/ray' in ${cwd}`.yellow);
22
+ }
16
23
  return {
17
- name: '@ray-js/build-plugin-ray',
24
+ name: LOG_PREFIX,
18
25
  setup() {
19
26
  shared_1.log.verbose(LOG_PREFIX, 'setup', api);
20
- this.generateRayBootstrap();
21
27
  },
22
28
  configWebpack({ config }) {
23
- shared_1.log.verbose(LOG_PREFIX, 'ray folder', rayFolder.blue.underline);
24
- config.resolve.alias.set('ray', rayFolder);
25
- },
26
- generateRayBootstrap() {
27
- const root = path_1.default.join(__dirname, '../templates');
28
- fs_extra_1.default.copySync(root, rayFolder);
29
+ shared_1.log.verbose(LOG_PREFIX, 'ray folder', rayMod.blue.underline);
30
+ config.resolve.alias.set('ray', rayMod);
29
31
  },
30
32
  };
31
33
  }
32
34
  exports.default = PluginRay;
33
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/build-plugin-ray",
3
- "version": "0.6.21",
3
+ "version": "0.6.22-beta-2",
4
4
  "description": "Ray build plugin for ray/framework",
5
5
  "keywords": [
6
6
  "ray"
@@ -8,9 +8,7 @@
8
8
  "license": "MIT",
9
9
  "main": "lib/index.js",
10
10
  "files": [
11
- "lib",
12
- "templates",
13
- "typings"
11
+ "lib"
14
12
  ],
15
13
  "publishConfig": {
16
14
  "access": "public",
@@ -22,12 +20,13 @@
22
20
  "watch": "tsc -p ./tsconfig.build.json --watch"
23
21
  },
24
22
  "dependencies": {
25
- "@ray-js/shared": "^0.6.21",
23
+ "@ray-js/shared": "^0.6.22-beta-2",
26
24
  "colors": "1.4.0",
27
- "fs-extra": "^10.0.0"
25
+ "fs-extra": "^10.0.0",
26
+ "slash": "^3.0.0"
28
27
  },
29
28
  "devDependencies": {
30
- "@ray-js/types": "^0.6.21",
29
+ "@ray-js/types": "^0.6.22-beta-2",
31
30
  "@types/fs-extra": "^9.0.13"
32
31
  },
33
32
  "maintainers": [
@@ -36,6 +35,6 @@
36
35
  "email": "tuyafe@tuya.com"
37
36
  }
38
37
  ],
39
- "gitHead": "cbb81571d068e6997e9b1fe95198c1b0275112e7",
38
+ "gitHead": "5d621bf1561047175b967cdf3aa35446f7d7198a",
40
39
  "repository": {}
41
40
  }
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AACA,oDAA2B;AAC3B,gDAAuB;AACvB,wDAA0B;AAC1B,2CAAoC;AAEpC,gBAAM,CAAC,MAAM,EAAE,CAAA;AAEf,MAAM,cAAc,GAAG,MAAM,CAAA;AAE7B,MAAM,UAAU,GAAG,kBAAkB,CAAA;AAErC,SAAwB,SAAS,CAAC,GAAQ;IACxC,MAAM,EACJ,OAAO,EAAE,EAAE,GAAG,EAAE,GACjB,GAAG,GAAG,CAAA;IACP,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAA;IAChD,OAAO;QACL,IAAI,EAAE,0BAA0B;QAChC,KAAK;YACH,YAAG,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,EAAE,GAAG,CAAC,CAAA;YACrC,IAAI,CAAC,oBAAoB,EAAE,CAAA;QAC7B,CAAC;QACD,aAAa,CAAC,EAAE,MAAM,EAAE;YACtB,YAAG,CAAC,OAAO,CAAC,UAAU,EAAE,YAAY,EAAE,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YAC/D,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;QAC5C,CAAC;QACD,oBAAoB;YAClB,MAAM,IAAI,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;YACjD,kBAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;QAC/B,CAAC;KACF,CAAA;AACH,CAAC;AApBD,4BAoBC"}
@@ -1,19 +0,0 @@
1
- # Ray
2
-
3
- 由 `@ray-js/build-plugin-ray` 进行文件内容的生成,不要进行对该文件夹下任何文件进行修改。
4
-
5
- 实现 `import * form 'ray';` 的导出,通过 `webpack.resolve.alias` 来配置构建。
6
-
7
- 底层由 `@ray-js/framework` 进行实现,主要包含对应应用类型(web, wechat tuya)执行的上下文 PageInstanceContext 来进行运行时的框架抹平完成应用的同构。
8
-
9
- 受限于小程序厂商的能力,尽量在此基础上,以 web 标准开发进行抹平,业务开发也尽可能的保持面向 WEB 开发的心智。
10
-
11
- build-plugin-ray/template 目录说明
12
-
13
- ```
14
- template
15
- ├── index.ts # 构建web、小程序时,导入的模块 `import * form 'ray';`
16
- ├── main.mini.tsx # 小程序(tuya、wechat等)构建入口文件
17
- ├── main.tsx # web构建入口文件
18
- └── README.md
19
- ```
@@ -1,5 +0,0 @@
1
- export * from '@ray-js/framework' // 由构建器别名替换到 @ray-js/framework-mp
2
- import router from '@ray-js/router' // 由构建器别名替换到 @ray-js/router-mp
3
- import location from '@ray-js/location'
4
-
5
- export { router, location }
@@ -1,10 +0,0 @@
1
- //@ts-nocheck
2
- import { createRouter } from '@ray-js/router-mp'
3
- // eslint-disable-next-line @typescript-eslint/no-var-requires
4
- const routesModule = require('@/routes.config')
5
-
6
- createRouter({
7
- routes: routesModule.routes || [],
8
- tabBar: routesModule.tabBar || {},
9
- subpackages: routesModule.subpackages || [],
10
- })
@@ -1,17 +0,0 @@
1
- import { createApp } from '@ray-js/framework'
2
-
3
- import App from '@/app'
4
- import * as globalConfig from '@/global.config'
5
- import * as routesConfig from '@/routes.config'
6
- import { PAGES } from './router.config'
7
-
8
- const globalConfigDefault = globalConfig.default || {}
9
- const globalConfigTarget = globalConfig[process.env.PLATFORM] || {}
10
-
11
- createApp({
12
- app: App,
13
- globalConfig: { ...globalConfigTarget, ...globalConfigDefault },
14
- pages: PAGES,
15
- routes: routesConfig.routes,
16
- tabBar: routesConfig.tabBar || {},
17
- })
@@ -1,33 +0,0 @@
1
- declare module '*.less'
2
-
3
- type RequestRes = {
4
- data: string
5
- statusCode: number
6
- header: Record<string, string>
7
- cookies: Array<string>
8
- profile: any
9
- taskId: string
10
- }
11
-
12
- type RequestParams = {
13
- url: string
14
- data?: string
15
- header?: Record<string, string>
16
- timeout?: number
17
- method?: string
18
- dataType?: string
19
- responseType?: string
20
- enableHttp2?: boolean
21
- enableQuic?: boolean
22
- enableCache?: boolean
23
- success?: (successRes: RequestRes) => void
24
- fail?: (successRes: RequestRes) => void
25
- complete?: (successRes: RequestRes) => void
26
- }
27
- declare global {
28
- interface Window {
29
- devToolsExtension?: () => any
30
- }
31
- }
32
-
33
- export {}