@ray-js/babel-preset-standard 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/CHANGELOG.md +13 -0
- package/README.md +3 -0
- package/__fixtures__/commonjs/.babelrc +6 -0
- package/__fixtures__/commonjs/code.js +24 -0
- package/__fixtures__/commonjs/output.js +16 -0
- package/__fixtures__/corejs/.babelrc +6 -0
- package/__fixtures__/corejs/code.js +17 -0
- package/__fixtures__/corejs/output.js +9 -0
- package/__fixtures__/dead-code/.babelrc +6 -0
- package/__fixtures__/dead-code/code.js +15 -0
- package/__fixtures__/dead-code/output.js +7 -0
- package/__fixtures__/esmodule/.babelrc +6 -0
- package/__fixtures__/esmodule/code.js +16 -0
- package/__fixtures__/esmodule/output.js +29 -0
- package/__tests__/index.test.js +8 -0
- package/index.d.ts +17 -0
- package/index.js +35 -0
- package/jest.config.js +5 -0
- package/package.json +45 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
4
|
+
|
|
5
|
+
## [0.3.0-beta.1c347991](./compare/v0.3.0-beta.3402439d...v0.3.0-beta.1c347991) (2022-05-12)
|
|
6
|
+
|
|
7
|
+
**Note:** Version bump only for package @ray-js/babel-preset-standard
|
|
8
|
+
|
|
9
|
+
## [0.3.0-beta.3402439d](./compare/v0.3.0-beta.ea0631...v0.3.0-beta.3402439d) (2022-05-12)
|
|
10
|
+
|
|
11
|
+
### Reverts
|
|
12
|
+
|
|
13
|
+
- Revert "v0.3.0-beta.ea0631" ([a9fda1b](./commit/a9fda1bbedacc961754697d5c2cada52b2b220e1))
|
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault').default;
|
|
4
|
+
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.default = View;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require('react'));
|
|
9
|
+
|
|
10
|
+
var isWeb = true;
|
|
11
|
+
var isWechat = false;
|
|
12
|
+
var isTuya = false;
|
|
13
|
+
|
|
14
|
+
function View() {
|
|
15
|
+
if (isWeb) {
|
|
16
|
+
return /*#__PURE__*/ _react.default.createElement('div', null, '1');
|
|
17
|
+
} else if (isWechat) {
|
|
18
|
+
return /*#__PURE__*/ _react.default.createElement('div', null, '2');
|
|
19
|
+
} else if (isTuya) {
|
|
20
|
+
return /*#__PURE__*/ _react.default.createElement('div', null, '3');
|
|
21
|
+
} else {
|
|
22
|
+
return /*#__PURE__*/ _react.default.createElement('div', null, '4');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault').default;
|
|
4
|
+
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.default = View;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require('react'));
|
|
9
|
+
|
|
10
|
+
var isWeb = true;
|
|
11
|
+
var isWechat = false;
|
|
12
|
+
var isTuya = false;
|
|
13
|
+
|
|
14
|
+
function View() {
|
|
15
|
+
return /*#__PURE__*/ _react.default.createElement('div', null, '1');
|
|
16
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
var isWeb = true;
|
|
3
|
+
var isWechat = false;
|
|
4
|
+
var isTuya = false;
|
|
5
|
+
export default function View() {
|
|
6
|
+
[1, 2, 3].includes(2);
|
|
7
|
+
|
|
8
|
+
if (isWeb) {
|
|
9
|
+
return /*#__PURE__*/ React.createElement('div', null, '1');
|
|
10
|
+
} else if (isWechat) {
|
|
11
|
+
return /*#__PURE__*/ React.createElement('div', null, '2');
|
|
12
|
+
} else if (isTuya) {
|
|
13
|
+
return /*#__PURE__*/ React.createElement('div', null, '3');
|
|
14
|
+
} else {
|
|
15
|
+
return /*#__PURE__*/ React.createElement('div', null, '4');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import 'core-js/modules/es.array.includes.js';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
var isWeb = true;
|
|
4
|
+
var isWechat = false;
|
|
5
|
+
var isTuya = false;
|
|
6
|
+
export default function View() {
|
|
7
|
+
[1, 2, 3].includes(2);
|
|
8
|
+
return /*#__PURE__*/ React.createElement('div', null, '1');
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
var isWeb = true;
|
|
3
|
+
var isWechat = false;
|
|
4
|
+
var isTuya = false;
|
|
5
|
+
export default function View() {
|
|
6
|
+
if (isWeb) {
|
|
7
|
+
return /*#__PURE__*/ React.createElement('div', null, '1');
|
|
8
|
+
} else if (isWechat) {
|
|
9
|
+
return /*#__PURE__*/ React.createElement('div', null, '2');
|
|
10
|
+
} else if (isTuya) {
|
|
11
|
+
return /*#__PURE__*/ React.createElement('div', null, '3');
|
|
12
|
+
} else {
|
|
13
|
+
return /*#__PURE__*/ React.createElement('div', null, '4');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {isWeb, isWechat, isTuya } from '@ray-js/env'
|
|
3
|
+
|
|
4
|
+
class View {
|
|
5
|
+
init() {
|
|
6
|
+
if (isWeb) {
|
|
7
|
+
return <div>1</div>;
|
|
8
|
+
} else if (isWechat) {
|
|
9
|
+
return <div>2</div>;
|
|
10
|
+
} else if (isTuya) {
|
|
11
|
+
return <div>3</div>;
|
|
12
|
+
} else {
|
|
13
|
+
return <div>4</div>;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import _classCallCheck from '@babel/runtime/helpers/esm/classCallCheck';
|
|
2
|
+
import _createClass from '@babel/runtime/helpers/esm/createClass';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { isWeb, isWechat, isTuya } from '@ray-js/env';
|
|
5
|
+
|
|
6
|
+
var View = /*#__PURE__*/ (function () {
|
|
7
|
+
function View() {
|
|
8
|
+
_classCallCheck(this, View);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
_createClass(View, [
|
|
12
|
+
{
|
|
13
|
+
key: 'init',
|
|
14
|
+
value: function init() {
|
|
15
|
+
if (isWeb) {
|
|
16
|
+
return /*#__PURE__*/ React.createElement('div', null, '1');
|
|
17
|
+
} else if (isWechat) {
|
|
18
|
+
return /*#__PURE__*/ React.createElement('div', null, '2');
|
|
19
|
+
} else if (isTuya) {
|
|
20
|
+
return /*#__PURE__*/ React.createElement('div', null, '3');
|
|
21
|
+
} else {
|
|
22
|
+
return /*#__PURE__*/ React.createElement('div', null, '4');
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
return View;
|
|
29
|
+
})();
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Target } from '@ray-js/types';
|
|
2
|
+
|
|
3
|
+
export type Modules = 'amd' | 'umd' | 'systemjs' | 'commonjs' | 'cjs' | 'auto' | false;
|
|
4
|
+
|
|
5
|
+
declare type PresetOption = {
|
|
6
|
+
modules: Modules;
|
|
7
|
+
jsx: 'react' | 'preserve';
|
|
8
|
+
platform: Target;
|
|
9
|
+
macro: boolean;
|
|
10
|
+
useBuiltIns?: false;
|
|
11
|
+
};
|
|
12
|
+
declare const _default: (
|
|
13
|
+
api: object,
|
|
14
|
+
options: PresetOption,
|
|
15
|
+
dirname: string
|
|
16
|
+
) => import('@babel/core').PluginObj<import('@babel/core').PluginPass>;
|
|
17
|
+
export default _default;
|
package/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const { declare } = require('@babel/helper-plugin-utils');
|
|
2
|
+
|
|
3
|
+
function preset(api, presetOption) {
|
|
4
|
+
api.assertVersion(7);
|
|
5
|
+
|
|
6
|
+
const { modules = 'auto', jsx = 'react', macro = true, useBuiltIns } = presetOption || {};
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
presets: [
|
|
10
|
+
[
|
|
11
|
+
require.resolve('@ray-js/babel-preset-base'),
|
|
12
|
+
{
|
|
13
|
+
loose: false,
|
|
14
|
+
targets: { browsers: '> 0.25%, not dead' },
|
|
15
|
+
modules: modules,
|
|
16
|
+
useBuiltIns,
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
jsx === 'react' && [require.resolve('@babel/preset-react')],
|
|
20
|
+
].filter(Boolean),
|
|
21
|
+
plugins: [
|
|
22
|
+
jsx === 'preserve' && require.resolve('@babel/plugin-syntax-jsx'),
|
|
23
|
+
macro && require.resolve('babel-plugin-macros'), // remax 中的 macro 需要
|
|
24
|
+
// require.resolve('babel-plugin-minify-dead-code-elimination'),
|
|
25
|
+
require.resolve('babel-plugin-minify-dead-code-elimination-while-loop-fixed'),
|
|
26
|
+
require.resolve('babel-plugin-transform-prune-unused-imports'),
|
|
27
|
+
[require.resolve('@babel/plugin-proposal-decorators'), { legacy: true }],
|
|
28
|
+
require.resolve('@babel/plugin-proposal-nullish-coalescing-operator'),
|
|
29
|
+
require.resolve('@babel/plugin-proposal-object-rest-spread'),
|
|
30
|
+
require.resolve('@babel/plugin-proposal-optional-chaining'),
|
|
31
|
+
].filter(Boolean),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = declare(preset);
|
package/jest.config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ray-js/babel-preset-standard",
|
|
3
|
+
"version": "0.3.0-beta.1c347991",
|
|
4
|
+
"description": "Ray babel-preset-standard",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ray"
|
|
7
|
+
],
|
|
8
|
+
"author": "子长 <zichang.nong@tuya.com>",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"main": "index.js",
|
|
11
|
+
"types": "index.d.js",
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public",
|
|
14
|
+
"registry": "https://registry.npmjs.org"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"test": "jest"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@babel/plugin-proposal-decorators": "^7.15.4",
|
|
21
|
+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.5",
|
|
22
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.15.6",
|
|
23
|
+
"@babel/plugin-proposal-optional-chaining": "^7.14.5",
|
|
24
|
+
"@babel/plugin-syntax-jsx": "^7.14.5",
|
|
25
|
+
"@babel/preset-react": "^7.14.5",
|
|
26
|
+
"@ray-js/babel-preset-base": "^0.3.0-beta.1c347991",
|
|
27
|
+
"babel-plugin-macros": "^3.1.0",
|
|
28
|
+
"babel-plugin-minify-dead-code-elimination-while-loop-fixed": "^0.3.0",
|
|
29
|
+
"babel-plugin-transform-prune-unused-imports": "^1.0.1"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@ray-js/types": "^0.3.0-beta.1c347991",
|
|
33
|
+
"babel-plugin-tester": "^10.1.0",
|
|
34
|
+
"jest": "^27.2.0",
|
|
35
|
+
"ts-jest": "^27.0.5"
|
|
36
|
+
},
|
|
37
|
+
"maintainers": [
|
|
38
|
+
{
|
|
39
|
+
"name": "tuyafe",
|
|
40
|
+
"email": "tuyafe@tuya.com"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"gitHead": "e0bd013022ddda63380d3c9e20fd8cadb46cd61f",
|
|
44
|
+
"repository": {}
|
|
45
|
+
}
|