fix(node/types): Add simplify (#5105)

This commit is contained in:
狒狒神 2022-07-05 12:11:11 +08:00 committed by GitHub
parent a27c14357c
commit 2a29b50c5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -866,6 +866,8 @@ export interface ConstModulesConfig {
/// https://swc.rs/docs/configuring-swc.html#jsctransformoptimizerjsonify /// https://swc.rs/docs/configuring-swc.html#jsctransformoptimizerjsonify
export interface OptimizerConfig { export interface OptimizerConfig {
/// https://swc.rs/docs/configuration/compilation#jsctransformoptimizersimplify
simplify?: boolean;
/// https://swc.rs/docs/configuring-swc.html#jsctransformoptimizerglobals /// https://swc.rs/docs/configuring-swc.html#jsctransformoptimizerglobals
globals?: GlobalPassOption; globals?: GlobalPassOption;
/// https://swc.rs/docs/configuring-swc.html#jsctransformoptimizerjsonify /// https://swc.rs/docs/configuring-swc.html#jsctransformoptimizerjsonify
@ -950,7 +952,7 @@ export interface BaseModuleConfig {
lazy?: boolean | string[]; lazy?: boolean | string[];
/** /**
* @deprecated Use the `importInterop` option instead. * @deprecated Use the `importInterop` option instead.
* *
* By default, when using exports with swc a non-enumerable __esModule property is exported. * By default, when using exports with swc a non-enumerable __esModule property is exported.
* This property is then used to determine if the import is the default export or if * This property is then used to determine if the import is the default export or if
* it contains the default export. * it contains the default export.
@ -963,86 +965,86 @@ export interface BaseModuleConfig {
noInterop?: boolean; noInterop?: boolean;
/** /**
* Defaults to `swc`. * Defaults to `swc`.
* *
* CommonJS modules and ECMAScript modules are not fully compatible. * CommonJS modules and ECMAScript modules are not fully compatible.
* However, compilers, bundlers and JavaScript runtimes developed different strategies * However, compilers, bundlers and JavaScript runtimes developed different strategies
* to make them work together as well as possible. * to make them work together as well as possible.
* *
* - `swc` (alias: `babel`) * - `swc` (alias: `babel`)
* *
* When using exports with `swc` a non-enumerable `__esModule` property is exported * When using exports with `swc` a non-enumerable `__esModule` property is exported
* This property is then used to determine if the import is the default export * This property is then used to determine if the import is the default export
* or if it contains the default export. * or if it contains the default export.
* *
* ```javascript * ```javascript
* import foo from "foo"; * import foo from "foo";
* import { bar } from "bar"; * import { bar } from "bar";
* foo; * foo;
* bar; * bar;
* *
* // Is compiled to ... * // Is compiled to ...
* *
* "use strict"; * "use strict";
* *
* function _interopRequireDefault(obj) { * function _interopRequireDefault(obj) {
* return obj && obj.__esModule ? obj : { default: obj }; * return obj && obj.__esModule ? obj : { default: obj };
* } * }
* *
* var _foo = _interopRequireDefault(require("foo")); * var _foo = _interopRequireDefault(require("foo"));
* var _bar = require("bar"); * var _bar = require("bar");
* *
* _foo.default; * _foo.default;
* _bar.bar; * _bar.bar;
* ``` * ```
* *
* When this import interop is used, if both the imported and the importer module are compiled * When this import interop is used, if both the imported and the importer module are compiled
* with swc they behave as if none of them was compiled. * with swc they behave as if none of them was compiled.
* *
* This is the default behavior. * This is the default behavior.
* *
* - `node` * - `node`
* *
* When importing CommonJS files (either directly written in CommonJS, or generated with a compiler) * When importing CommonJS files (either directly written in CommonJS, or generated with a compiler)
* Node.js always binds the `default` export to the value of `module.exports`. * Node.js always binds the `default` export to the value of `module.exports`.
* *
* ```javascript * ```javascript
* import foo from "foo"; * import foo from "foo";
* import { bar } from "bar"; * import { bar } from "bar";
* foo; * foo;
* bar; * bar;
* *
* // Is compiled to ... * // Is compiled to ...
* *
* "use strict"; * "use strict";
* *
* var _foo = require("foo"); * var _foo = require("foo");
* var _bar = require("bar"); * var _bar = require("bar");
* *
* _foo; * _foo;
* _bar.bar; * _bar.bar;
* ``` * ```
* This is not exactly the same as what Node.js does since swc allows accessing any property of `module.exports` * This is not exactly the same as what Node.js does since swc allows accessing any property of `module.exports`
* as a named export, while Node.js only allows importing statically analyzable properties of `module.exports`. * as a named export, while Node.js only allows importing statically analyzable properties of `module.exports`.
* However, any import working in Node.js will also work when compiled with swc using `importInterop: "node"`. * However, any import working in Node.js will also work when compiled with swc using `importInterop: "node"`.
* *
* - `none` * - `none`
* *
* If you know that the imported file has been transformed with a compiler that stores the `default` export on * If you know that the imported file has been transformed with a compiler that stores the `default` export on
* `exports.default` (such as swc or Babel), you can safely omit the `_interopRequireDefault` helper. * `exports.default` (such as swc or Babel), you can safely omit the `_interopRequireDefault` helper.
* *
* ```javascript * ```javascript
* import foo from "foo"; * import foo from "foo";
* import { bar } from "bar"; * import { bar } from "bar";
* foo; * foo;
* bar; * bar;
* *
* // Is compiled to ... * // Is compiled to ...
* *
* "use strict"; * "use strict";
* *
* var _foo = require("foo"); * var _foo = require("foo");
* var _bar = require("bar"); * var _bar = require("bar");
* *
* _foo.default; * _foo.default;
* _bar.bar; * _bar.bar;
* ``` * ```