@ray-js/babel-preset-base 0.3.0-beta.1c347991
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/README.md +1 -0
- package/lib/index.d.ts +17 -0
- package/lib/index.js +57 -0
- package/package.json +41 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @ray-js/babel-preset-base
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare type Options = {
|
|
2
|
+
modules?: 'amd' | 'umd' | 'systemjs' | 'commonjs' | 'cjs' | 'auto' | false;
|
|
3
|
+
targets?: Record<string, string>;
|
|
4
|
+
useBuiltIns?: 'usage' | 'entry' | false;
|
|
5
|
+
corejs?: {
|
|
6
|
+
version: string;
|
|
7
|
+
proposals?: boolean;
|
|
8
|
+
};
|
|
9
|
+
loose?: boolean;
|
|
10
|
+
transformRuntime?: boolean;
|
|
11
|
+
runtimeHelpersUseESModules?: boolean;
|
|
12
|
+
runtimeVersion?: string;
|
|
13
|
+
debug?: boolean;
|
|
14
|
+
additionalTargets?: Record<string, string> | string;
|
|
15
|
+
};
|
|
16
|
+
declare const _default: (api: object, options: Options, dirname: string) => import("@babel/core").PluginObj<import("@babel/core").PluginPass>;
|
|
17
|
+
export default _default;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const helper_plugin_utils_1 = require("@babel/helper-plugin-utils");
|
|
4
|
+
const defaultTargets = {
|
|
5
|
+
android: '5',
|
|
6
|
+
ios: '10',
|
|
7
|
+
};
|
|
8
|
+
function buildTargets(options) {
|
|
9
|
+
const { additionalTargets } = options;
|
|
10
|
+
if (typeof additionalTargets === 'string') {
|
|
11
|
+
return additionalTargets;
|
|
12
|
+
}
|
|
13
|
+
return Object.assign({}, defaultTargets, additionalTargets);
|
|
14
|
+
}
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
exports.default = (0, helper_plugin_utils_1.declare)((api, options, _dirname) => {
|
|
17
|
+
api.assertVersion('^7.0.0');
|
|
18
|
+
const targets = options.targets || buildTargets(options);
|
|
19
|
+
const { modules = 'auto', useBuiltIns = 'usage', corejs = { version: '3.17', proposals: false }, loose = false, transformRuntime = true, runtimeHelpersUseESModules = !modules, runtimeVersion = '^7.15.0', } = options;
|
|
20
|
+
const debug = typeof options.debug === 'boolean' ? options.debug : false;
|
|
21
|
+
return {
|
|
22
|
+
presets: ['native', 'ios', 'android'].includes(process.env.PLATFORM)
|
|
23
|
+
? [
|
|
24
|
+
[
|
|
25
|
+
require.resolve('@ray-js/babel-preset-ray-rn'),
|
|
26
|
+
{ framework: 'react', ts: true, buildComponent: true },
|
|
27
|
+
],
|
|
28
|
+
]
|
|
29
|
+
: [
|
|
30
|
+
[
|
|
31
|
+
require.resolve('@babel/preset-env'),
|
|
32
|
+
{
|
|
33
|
+
debug,
|
|
34
|
+
loose,
|
|
35
|
+
modules,
|
|
36
|
+
useBuiltIns,
|
|
37
|
+
corejs: corejs,
|
|
38
|
+
targets,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
[require.resolve('@babel/preset-typescript'), { allowNamespaces: true }],
|
|
42
|
+
].filter(Boolean),
|
|
43
|
+
plugins: [
|
|
44
|
+
transformRuntime && [
|
|
45
|
+
require.resolve('@babel/plugin-transform-runtime'),
|
|
46
|
+
{
|
|
47
|
+
absoluteRuntime: false,
|
|
48
|
+
useESModules: runtimeHelpersUseESModules,
|
|
49
|
+
corejs: false,
|
|
50
|
+
helpers: true,
|
|
51
|
+
regenerator: true,
|
|
52
|
+
version: runtimeVersion,
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
].filter(Boolean),
|
|
56
|
+
};
|
|
57
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ray-js/babel-preset-base",
|
|
3
|
+
"version": "0.3.0-beta.1c347991",
|
|
4
|
+
"description": "Ray babel-preset-base",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ray"
|
|
7
|
+
],
|
|
8
|
+
"author": "子长 <zichang.nong@tuya.com>",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"main": "lib/index.js",
|
|
11
|
+
"files": [
|
|
12
|
+
"lib"
|
|
13
|
+
],
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public",
|
|
16
|
+
"registry": "https://registry.npmjs.org"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"clean": "rm -rf lib",
|
|
20
|
+
"build": "tsc -p ./tsconfig.build.json",
|
|
21
|
+
"watch": "tsc -p ./tsconfig.build.json --watch"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@babel/helper-plugin-utils": "^7.14.5",
|
|
25
|
+
"@babel/plugin-transform-runtime": "^7.15.0",
|
|
26
|
+
"@babel/preset-env": "^7.15.4",
|
|
27
|
+
"@babel/preset-typescript": "^7.15.0",
|
|
28
|
+
"core-js": "^3.17.2"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/babel__helper-plugin-utils": "^7.10.0"
|
|
32
|
+
},
|
|
33
|
+
"maintainers": [
|
|
34
|
+
{
|
|
35
|
+
"name": "tuyafe",
|
|
36
|
+
"email": "tuyafe@tuya.com"
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"gitHead": "e0bd013022ddda63380d3c9e20fd8cadb46cd61f",
|
|
40
|
+
"repository": {}
|
|
41
|
+
}
|