@swc/core 1.2.66 → 1.2.70

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.
Files changed (4) hide show
  1. package/index.d.ts +5 -1
  2. package/index.js +19 -1
  3. package/package.json +15 -15
  4. package/types.d.ts +101 -3
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Plugin, ParseOptions, Module, Output, Options, Script, Program } from "./types";
1
+ import { Plugin, ParseOptions, Module, Output, Options, Script, Program, JsMinifyOptions } from "./types";
2
2
  export * from "./types";
3
3
  import { BundleInput } from "./spack";
4
4
  /**
@@ -7,6 +7,8 @@ import { BundleInput } from "./spack";
7
7
  export declare const version: any;
8
8
  export declare function plugins(ps: Plugin[]): Plugin;
9
9
  export declare class Compiler {
10
+ minify(src: string, opts?: JsMinifyOptions): Promise<Output>;
11
+ minifySync(src: string, opts?: JsMinifyOptions): Output;
10
12
  parse(src: string, options: ParseOptions & {
11
13
  isModule: false;
12
14
  }): Promise<Script>;
@@ -66,4 +68,6 @@ export declare function transformFileSync(path: string, options?: Options): Outp
66
68
  export declare function bundle(options?: BundleInput | string): Promise<{
67
69
  [name: string]: Output;
68
70
  }>;
71
+ export declare function minify(src: string, opts?: JsMinifyOptions): Promise<Output>;
72
+ export declare function minifySync(src: string, opts?: JsMinifyOptions): Output;
69
73
  export declare const DEFAULT_EXTENSIONS: readonly string[];
package/index.js CHANGED
@@ -30,7 +30,7 @@ var __rest = (this && this.__rest) || function (s, e) {
30
30
  return t;
31
31
  };
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.DEFAULT_EXTENSIONS = exports.bundle = exports.transformFileSync = exports.transformFile = exports.transformSync = exports.transform = exports.printSync = exports.print = exports.parseFileSync = exports.parseFile = exports.parseSync = exports.parse = exports.Compiler = exports.plugins = exports.version = void 0;
33
+ exports.DEFAULT_EXTENSIONS = exports.minifySync = exports.minify = exports.bundle = exports.transformFileSync = exports.transformFile = exports.transformSync = exports.transform = exports.printSync = exports.print = exports.parseFileSync = exports.parseFile = exports.parseSync = exports.parse = exports.Compiler = exports.plugins = exports.version = void 0;
34
34
  __exportStar(require("./types"), exports);
35
35
  const spack_1 = require("./spack");
36
36
  const helper_1 = require("@node-rs/helper");
@@ -50,6 +50,14 @@ function plugins(ps) {
50
50
  }
51
51
  exports.plugins = plugins;
52
52
  class Compiler {
53
+ minify(src, opts) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ return bindings.minify(src, toBuffer(opts !== null && opts !== void 0 ? opts : {}));
56
+ });
57
+ }
58
+ minifySync(src, opts) {
59
+ return bindings.minifySync(src, toBuffer(opts !== null && opts !== void 0 ? opts : {}));
60
+ }
53
61
  parse(src, options) {
54
62
  return __awaiter(this, void 0, void 0, function* () {
55
63
  options = options || { syntax: "ecmascript" };
@@ -217,6 +225,16 @@ function bundle(options) {
217
225
  return compiler.bundle(options);
218
226
  }
219
227
  exports.bundle = bundle;
228
+ function minify(src, opts) {
229
+ return __awaiter(this, void 0, void 0, function* () {
230
+ return compiler.minify(src, opts);
231
+ });
232
+ }
233
+ exports.minify = minify;
234
+ function minifySync(src, opts) {
235
+ return compiler.minifySync(src, opts);
236
+ }
237
+ exports.minifySync = minifySync;
220
238
  exports.DEFAULT_EXTENSIONS = Object.freeze([
221
239
  ".js",
222
240
  ".jsx",
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@swc/core",
3
- "version": "1.2.66",
3
+ "version": "1.2.70",
4
4
  "description": "Super-fast alternative for babel",
5
5
  "homepage": "https://swc.rs",
6
6
  "main": "./index.js",
7
7
  "author": "강동윤 <kdy1997.dev@gmail.com>",
8
- "license": "MIT",
8
+ "license": "Apache-2.0 AND MIT",
9
9
  "keywords": [
10
10
  "swc",
11
11
  "spack",
@@ -74,7 +74,7 @@
74
74
  "@types/node": "^14.14.41",
75
75
  "axios": "^0.21.1",
76
76
  "babel-plugin-transform-node-env-inline": "^0.4.3",
77
- "browserslist": "^4.16.5",
77
+ "browserslist": "^4.16.6",
78
78
  "core-js": "^2.6.11",
79
79
  "cross-env": "^7.0.3",
80
80
  "jest": "^27.0.1",
@@ -90,17 +90,17 @@
90
90
  "url": "https://opencollective.com/swc"
91
91
  },
92
92
  "optionalDependencies": {
93
- "@swc/core-win32-x64-msvc": "^1.2.66",
94
- "@swc/core-darwin-x64": "^1.2.66",
95
- "@swc/core-linux-x64-gnu": "^1.2.66",
96
- "@swc/core-linux-x64-musl": "^1.2.66",
97
- "@swc/core-win32-ia32-msvc": "^1.2.66",
98
- "@swc/core-linux-arm64-gnu": "^1.2.66",
99
- "@swc/core-linux-arm-gnueabihf": "^1.2.66",
100
- "@swc/core-darwin-arm64": "^1.2.66",
101
- "@swc/core-android-arm64": "^1.2.66",
102
- "@swc/core-freebsd-x64": "^1.2.66",
103
- "@swc/core-linux-arm64-musl": "^1.2.66",
104
- "@swc/core-win32-arm64-msvc": "^1.2.66"
93
+ "@swc/core-win32-x64-msvc": "^1.2.70",
94
+ "@swc/core-darwin-x64": "^1.2.70",
95
+ "@swc/core-linux-x64-gnu": "^1.2.70",
96
+ "@swc/core-linux-x64-musl": "^1.2.70",
97
+ "@swc/core-win32-ia32-msvc": "^1.2.70",
98
+ "@swc/core-linux-arm64-gnu": "^1.2.70",
99
+ "@swc/core-linux-arm-gnueabihf": "^1.2.70",
100
+ "@swc/core-darwin-arm64": "^1.2.70",
101
+ "@swc/core-android-arm64": "^1.2.70",
102
+ "@swc/core-freebsd-x64": "^1.2.70",
103
+ "@swc/core-linux-arm64-musl": "^1.2.70",
104
+ "@swc/core-win32-arm64-msvc": "^1.2.70"
105
105
  }
106
106
  }
package/types.d.ts CHANGED
@@ -9,6 +9,86 @@ export declare type ParseOptions = ParserConfig & {
9
9
  */
10
10
  target?: JscTarget;
11
11
  };
12
+ export declare type TerserEcmaVersion = 5 | 2015 | 2016 | string | number;
13
+ export interface JsMinifyOptions {
14
+ compress?: TerserCompressOptions | boolean;
15
+ mangle?: TerserMangleOptions | boolean;
16
+ ecma?: TerserEcmaVersion;
17
+ keep_classnames?: boolean;
18
+ keep_fnames?: boolean;
19
+ module?: boolean;
20
+ safari10?: boolean;
21
+ toplevel?: boolean;
22
+ sourceMap?: boolean;
23
+ outputPath?: string;
24
+ }
25
+ export interface TerserCompressOptions {
26
+ arguments?: boolean;
27
+ arrows?: boolean;
28
+ booleans?: boolean;
29
+ booleans_as_integers?: boolean;
30
+ collapse_vars?: boolean;
31
+ comparisons?: boolean;
32
+ computed_props?: boolean;
33
+ conditionals?: boolean;
34
+ dead_code?: boolean;
35
+ defaults?: boolean;
36
+ directives?: boolean;
37
+ drop_console?: boolean;
38
+ drop_debugger?: boolean;
39
+ ecma?: TerserEcmaVersion;
40
+ evaluate?: boolean;
41
+ expression?: boolean;
42
+ global_defs?: any;
43
+ hoist_funs?: boolean;
44
+ hoist_props?: boolean;
45
+ hoist_vars?: boolean;
46
+ ie8?: boolean;
47
+ if_return?: boolean;
48
+ inline?: 0 | 1 | 2 | 3;
49
+ join_vars?: boolean;
50
+ keep_classnames?: boolean;
51
+ keep_fargs?: boolean;
52
+ keep_fnames?: boolean;
53
+ keep_infinity?: boolean;
54
+ loops?: boolean;
55
+ negate_iife?: boolean;
56
+ passes?: number;
57
+ properties?: boolean;
58
+ pure_getters?: any;
59
+ pure_funcs?: string[];
60
+ reduce_funcs?: boolean;
61
+ reduce_vars?: boolean;
62
+ sequences?: any;
63
+ side_effects?: boolean;
64
+ switches?: boolean;
65
+ top_retain?: any;
66
+ toplevel?: any;
67
+ typeofs?: boolean;
68
+ unsafe_passes?: boolean;
69
+ unsafe_arrows?: boolean;
70
+ unsafe_comps?: boolean;
71
+ unsafe_function?: boolean;
72
+ unsafe_math?: boolean;
73
+ unsafe_symbols?: boolean;
74
+ unsafe_methods?: boolean;
75
+ unsafe_proto?: boolean;
76
+ unsafe_regexp?: boolean;
77
+ unsafe_undefined?: boolean;
78
+ unused?: boolean;
79
+ module?: boolean;
80
+ }
81
+ export interface TerserMangleOptions {
82
+ props?: TerserManglePropertiesOptions;
83
+ top_level?: boolean;
84
+ keep_class_names?: boolean;
85
+ keep_fn_names?: boolean;
86
+ keep_private_props?: boolean;
87
+ ie8?: boolean;
88
+ safari10?: boolean;
89
+ }
90
+ export interface TerserManglePropertiesOptions {
91
+ }
12
92
  /**
13
93
  * Programmatic options.
14
94
  */
@@ -288,6 +368,8 @@ export interface EsParserConfig {
288
368
  privateMethod?: boolean;
289
369
  /**
290
370
  * Defaults to `false`
371
+ *
372
+ * @deprecated Always true because it's in ecmascript spec.
291
373
  */
292
374
  classProperty?: boolean;
293
375
  /**
@@ -302,6 +384,16 @@ export interface EsParserConfig {
302
384
  * Defaults to `false`
303
385
  */
304
386
  decoratorsBeforeExport?: boolean;
387
+ /**
388
+ * Defaults to `false`
389
+ */
390
+ exportDefaultFrom?: boolean;
391
+ /**
392
+ * Defaults to `false`
393
+ *
394
+ * @deprecated Always true because it's in ecmascript spec.
395
+ */
396
+ exportNamespaceFrom?: boolean;
305
397
  /**
306
398
  * Defaults to `false`
307
399
  */
@@ -314,16 +406,22 @@ export interface EsParserConfig {
314
406
  nullishCoalescing?: boolean;
315
407
  /**
316
408
  * Defaults to `false`
409
+ *
410
+ * @deprecated Always true because it's in ecmascript spec.
317
411
  */
318
- exportDefaultFrom?: boolean;
412
+ optionalChaining?: boolean;
319
413
  /**
320
414
  * Defaults to `false`
321
415
  */
322
- exportNamespaceFrom?: boolean;
416
+ importMeta?: boolean;
323
417
  /**
324
418
  * Defaults to `false`
325
419
  */
326
- importMeta?: boolean;
420
+ topLevelAwait?: boolean;
421
+ /**
422
+ * Defaults to `false`
423
+ */
424
+ importAssertions?: boolean;
327
425
  }
328
426
  /**
329
427
  * Options for trasnform.