@swc/core 1.5.23 → 1.5.25

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/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@swc/core",
3
- "version": "1.5.23",
3
+ "version": "1.5.25",
4
4
  "description": "Super-fast alternative for babel",
5
5
  "homepage": "https://swc.rs",
6
- "main": "./src/index.js",
6
+ "main": "./index.js",
7
7
  "author": "강동윤 <kdy1997.dev@gmail.com>",
8
8
  "license": "Apache-2.0",
9
9
  "keywords": [
@@ -44,7 +44,7 @@
44
44
  "registry": "https://registry.npmjs.org/",
45
45
  "access": "public"
46
46
  },
47
- "types": "./src/index.d.ts",
47
+ "types": "./index.d.ts",
48
48
  "scripts": {
49
49
  "postinstall": "node postinstall.js",
50
50
  "artifacts": "napi artifacts --npm-dir scripts/npm",
@@ -71,21 +71,21 @@
71
71
  },
72
72
  "files": [
73
73
  "CHANGELOG.md",
74
- "src/Visitor.d.ts",
75
- "src/index.d.ts",
76
- "src/spack.js",
77
- "src/util.d.ts",
74
+ "Visitor.d.ts",
75
+ "index.d.ts",
76
+ "spack.js",
77
+ "util.d.ts",
78
78
  "LICENSE",
79
- "src/Visitor.js",
80
- "src/binding.d.ts",
81
- "src/index.js",
82
- "src/types.d.ts",
83
- "src/util.js",
79
+ "Visitor.js",
80
+ "binding.d.ts",
81
+ "index.js",
82
+ "types.d.ts",
83
+ "util.js",
84
84
  "README.md",
85
85
  "binding.js",
86
86
  "package.json",
87
- "src/spack.d.ts",
88
- "src/types.js",
87
+ "spack.d.ts",
88
+ "types.js",
89
89
  "postinstall.js",
90
90
  "bindings/binding_core_wasm/pkg/binding_core_wasm.d.ts"
91
91
  ],
@@ -100,15 +100,15 @@
100
100
  "typescript": "^5.3.3"
101
101
  },
102
102
  "optionalDependencies": {
103
- "@swc/core-darwin-x64": "1.5.23",
104
- "@swc/core-win32-x64-msvc": "1.5.23",
105
- "@swc/core-linux-x64-gnu": "1.5.23",
106
- "@swc/core-linux-x64-musl": "1.5.23",
107
- "@swc/core-win32-ia32-msvc": "1.5.23",
108
- "@swc/core-linux-arm-gnueabihf": "1.5.23",
109
- "@swc/core-linux-arm64-gnu": "1.5.23",
110
- "@swc/core-darwin-arm64": "1.5.23",
111
- "@swc/core-linux-arm64-musl": "1.5.23",
112
- "@swc/core-win32-arm64-msvc": "1.5.23"
103
+ "@swc/core-darwin-x64": "1.5.25",
104
+ "@swc/core-win32-x64-msvc": "1.5.25",
105
+ "@swc/core-linux-x64-gnu": "1.5.25",
106
+ "@swc/core-linux-x64-musl": "1.5.25",
107
+ "@swc/core-win32-ia32-msvc": "1.5.25",
108
+ "@swc/core-linux-arm-gnueabihf": "1.5.25",
109
+ "@swc/core-linux-arm64-gnu": "1.5.25",
110
+ "@swc/core-darwin-arm64": "1.5.25",
111
+ "@swc/core-linux-arm64-musl": "1.5.25",
112
+ "@swc/core-win32-arm64-msvc": "1.5.25"
113
113
  }
114
114
  }
package/spack.d.ts ADDED
@@ -0,0 +1,51 @@
1
+ import { Options } from "@swc/types";
2
+ export type BundleInput = BundleOptions | BundleOptions[];
3
+ export declare const isLocalFile: RegExp;
4
+ export declare function compileBundleOptions(config: BundleInput | string | undefined): Promise<BundleInput>;
5
+ /**
6
+ * Usage: In `spack.config.js` / `spack.config.ts`, you can utilize type annotations (to get autocompletions) like
7
+ *
8
+ * ```ts
9
+ * import { config } from '@swc/core/spack';
10
+ *
11
+ * export default config({
12
+ * name: 'web',
13
+ * });
14
+ * ```
15
+ *
16
+ *
17
+ *
18
+ */
19
+ export declare function config(c: BundleInput): BundleInput;
20
+ export interface BundleOptions extends SpackConfig {
21
+ workingDir?: string;
22
+ }
23
+ /**
24
+ * `spack.config,js`
25
+ */
26
+ export interface SpackConfig {
27
+ /**
28
+ * @default process.env.NODE_ENV
29
+ */
30
+ mode?: Mode;
31
+ target?: Target;
32
+ entry: EntryConfig;
33
+ output: OutputConfig;
34
+ module: ModuleConfig;
35
+ options?: Options;
36
+ /**
37
+ * Modules to exclude from bundle.
38
+ */
39
+ externalModules?: string[];
40
+ }
41
+ export interface OutputConfig {
42
+ name: string;
43
+ path: string;
44
+ }
45
+ export interface ModuleConfig {
46
+ }
47
+ export type Mode = "production" | "development" | "none";
48
+ export type Target = "browser" | "node";
49
+ export type EntryConfig = string | string[] | {
50
+ [name: string]: string;
51
+ };
package/spack.js ADDED
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.config = exports.compileBundleOptions = exports.isLocalFile = void 0;
36
+ const path = __importStar(require("path"));
37
+ exports.isLocalFile = /^\.{0,2}\//; // starts with '/' './' '../'
38
+ function compileBundleOptions(config) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ const f = config === undefined ? "." : config;
41
+ try {
42
+ const filepath = typeof f === "string" ? f : "spack.config.js";
43
+ const fileModule = exports.isLocalFile.test(filepath)
44
+ ? path.resolve(filepath)
45
+ : filepath;
46
+ let configFromFile = require(fileModule);
47
+ if (configFromFile.default) {
48
+ configFromFile = configFromFile.default;
49
+ }
50
+ if (Array.isArray(configFromFile)) {
51
+ if (Array.isArray(f)) {
52
+ return [...configFromFile, ...f];
53
+ }
54
+ if (typeof f !== "string") {
55
+ configFromFile.push(f);
56
+ }
57
+ return configFromFile;
58
+ }
59
+ return Object.assign(Object.assign({}, configFromFile), (typeof config === "string" ? {} : config));
60
+ }
61
+ catch (e) {
62
+ if (typeof f === "string") {
63
+ throw new Error(`Error occurred while loading config file at ${config}: ${e}`);
64
+ }
65
+ return f;
66
+ }
67
+ });
68
+ }
69
+ exports.compileBundleOptions = compileBundleOptions;
70
+ /**
71
+ * Usage: In `spack.config.js` / `spack.config.ts`, you can utilize type annotations (to get autocompletions) like
72
+ *
73
+ * ```ts
74
+ * import { config } from '@swc/core/spack';
75
+ *
76
+ * export default config({
77
+ * name: 'web',
78
+ * });
79
+ * ```
80
+ *
81
+ *
82
+ *
83
+ */
84
+ function config(c) {
85
+ return c;
86
+ }
87
+ exports.config = config;
package/util.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function wrapNativeSuper(Class: any): never;
package/util.js ADDED
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.wrapNativeSuper = void 0;
4
+ //@ts-ignore
5
+ function wrapNativeSuper(Class) {
6
+ var _cache = typeof Map === "function" ? new Map() : undefined;
7
+ //@ts-ignore
8
+ exports.wrapNativeSuper = wrapNativeSuper = function wrapNativeSuper(Class) {
9
+ if (Class === null || !_isNativeFunction(Class))
10
+ return Class;
11
+ if (typeof Class !== "function") {
12
+ throw new TypeError("Super expression must either be null or a function");
13
+ }
14
+ if (typeof _cache !== "undefined") {
15
+ if (_cache.has(Class))
16
+ return _cache.get(Class);
17
+ _cache.set(Class, Wrapper);
18
+ }
19
+ function Wrapper() {
20
+ //@ts-ignore
21
+ return _construct(Class, arguments, _getPrototypeOf(this).constructor);
22
+ }
23
+ Wrapper.prototype = Object.create(Class.prototype, {
24
+ constructor: {
25
+ value: Wrapper,
26
+ enumerable: false,
27
+ writable: true,
28
+ configurable: true,
29
+ },
30
+ });
31
+ return _setPrototypeOf(Wrapper, Class);
32
+ };
33
+ return wrapNativeSuper(Class);
34
+ }
35
+ exports.wrapNativeSuper = wrapNativeSuper;
36
+ function isNativeReflectConstruct() {
37
+ if (typeof Reflect === "undefined" || !Reflect.construct)
38
+ return false;
39
+ //@ts-ignore
40
+ if (Reflect.construct.sham)
41
+ return false;
42
+ if (typeof Proxy === "function")
43
+ return true;
44
+ try {
45
+ Date.prototype.toString.call(Reflect.construct(Date, [], function () { }));
46
+ return true;
47
+ }
48
+ catch (e) {
49
+ return false;
50
+ }
51
+ }
52
+ //@ts-ignore
53
+ function _construct(Parent, args, Class) {
54
+ if (isNativeReflectConstruct()) {
55
+ //@ts-ignore
56
+ _construct = Reflect.construct;
57
+ }
58
+ else {
59
+ //@ts-ignore
60
+ _construct = function _construct(Parent, args, Class) {
61
+ var a = [null];
62
+ a.push.apply(a, args);
63
+ //@ts-ignore
64
+ var Constructor = Function.bind.apply(Parent, a);
65
+ //@ts-ignore
66
+ var instance = new Constructor();
67
+ if (Class)
68
+ _setPrototypeOf(instance, Class.prototype);
69
+ return instance;
70
+ };
71
+ }
72
+ //@ts-ignore
73
+ return _construct.apply(null, arguments);
74
+ }
75
+ function _isNativeFunction(fn) {
76
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
77
+ }
78
+ //@ts-ignore
79
+ function _setPrototypeOf(o, p) {
80
+ //@ts-ignore
81
+ _setPrototypeOf =
82
+ Object.setPrototypeOf ||
83
+ //@ts-ignore
84
+ function _setPrototypeOf(o, p) {
85
+ o.__proto__ = p;
86
+ return o;
87
+ };
88
+ return _setPrototypeOf(o, p);
89
+ }
90
+ //@ts-ignore
91
+ function _getPrototypeOf(o) {
92
+ //@ts-ignore
93
+ _getPrototypeOf = Object.setPrototypeOf
94
+ ? Object.getPrototypeOf
95
+ : function _getPrototypeOf(
96
+ //@ts-ignore
97
+ o) {
98
+ return o.__proto__ || Object.getPrototypeOf(o);
99
+ };
100
+ return _getPrototypeOf(o);
101
+ }
102
+ module.exports = {
103
+ wrapNativeSuper,
104
+ };