@faasjs/load 0.0.2-beta.324 → 0.0.2-beta.328

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/dist/index.js CHANGED
@@ -1,8 +1,6 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
5
  var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
6
  var __export = (target, all) => {
@@ -17,9 +15,6 @@ var __reExport = (target, module2, copyDefault, desc) => {
17
15
  }
18
16
  return target;
19
17
  };
20
- var __toESM = (module2, isNodeMode) => {
21
- return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
- };
23
18
  var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
19
  return (module2, temp) => {
25
20
  return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
@@ -85,69 +80,7 @@ var import_deep_merge2 = require("@faasjs/deep_merge");
85
80
  var import_fs2 = require("fs");
86
81
  var import_rollup = require("rollup");
87
82
  var import_path2 = require("path");
88
- var import_plugin_node_resolve = __toESM(require("@rollup/plugin-node-resolve"));
89
- var import_core = require("@swc/core");
90
- var FAAS_PACKAGES = [
91
- "@faasjs/ant-design",
92
- "@faasjs/aws",
93
- "@faasjs/browser",
94
- "@faasjs/cli",
95
- "@faasjs/cloud_function",
96
- "create-faas-app",
97
- "@faasjs/deep_merge",
98
- "@faasjs/deployer",
99
- "@faasjs/eslint-config-recommended",
100
- "@faasjs/eslint-config-vue",
101
- "faasjs",
102
- "@faasjs/func",
103
- "@faasjs/graphql-server",
104
- "@faasjs/http",
105
- "@faasjs/knex",
106
- "@faasjs/load",
107
- "@faasjs/logger",
108
- "@faasjs/react",
109
- "@faasjs/redis",
110
- "@faasjs/request",
111
- "@faasjs/server",
112
- "@faasjs/tencentcloud",
113
- "@faasjs/test",
114
- "@faasjs/vue-plugin"
115
- ];
116
- var NODE_PACKAGES = [
117
- "async_hooks",
118
- "child_process",
119
- "cluster",
120
- "crypto",
121
- "dns",
122
- "events",
123
- "fs",
124
- "http",
125
- "http2",
126
- "https",
127
- "inspector",
128
- "net",
129
- "os",
130
- "path",
131
- "perf_hooks",
132
- "process",
133
- "querystring",
134
- "readline",
135
- "repl",
136
- "stream",
137
- "string_decoder",
138
- "tls",
139
- "trace_events",
140
- "tty",
141
- "dgram",
142
- "udp4",
143
- "url",
144
- "util",
145
- "v8",
146
- "vm",
147
- "wasi",
148
- "worker_threads",
149
- "zlib"
150
- ];
83
+ var import_ts_transform = require("@faasjs/ts-transform");
151
84
  function resolveModuleBasePath(moduleName) {
152
85
  const moduleMainFilePath = require.resolve(moduleName);
153
86
  const moduleNameParts = moduleName.split("/");
@@ -194,61 +127,48 @@ function findModule(list, key, options = { excludes: [] }) {
194
127
  }
195
128
  deps.map((d) => findModule(list, d, options));
196
129
  }
197
- function swc(options) {
130
+ function swc(externalModules) {
198
131
  return {
199
132
  name: "swc",
200
133
  async transform(code, filename) {
201
- options.filename = filename;
202
- return (0, import_core.transform)(code, options);
134
+ return (0, import_ts_transform.bundle)({
135
+ filename,
136
+ externalModules
137
+ });
203
138
  }
204
139
  };
205
140
  }
206
- async function loadTs(filename, options = Object.create(null)) {
141
+ async function loadTs(filename, options = /* @__PURE__ */ Object.create(null)) {
207
142
  var _a;
208
143
  const PackageJSON = require(`${process.cwd()}/package.json`);
209
- const external = PackageJSON.dependencies ? FAAS_PACKAGES.concat(Object.keys(PackageJSON.dependencies)) : FAAS_PACKAGES;
144
+ const external = PackageJSON.dependencies ? Object.keys(PackageJSON.dependencies) : [];
210
145
  if (options.modules && options.modules.excludes == null)
211
146
  options.modules.excludes = [];
212
147
  const input = (0, import_deep_merge2.deepMerge)({
213
148
  input: filename,
214
149
  external,
215
- plugins: [
216
- (0, import_plugin_node_resolve.default)({
217
- extensions: [
218
- ".ts",
219
- ".tsx",
220
- ".js",
221
- ".jsx"
222
- ]
223
- }),
224
- swc({
225
- jsc: {
226
- parser: { syntax: "typescript" },
227
- target: "es2019"
228
- }
229
- })
230
- ],
150
+ plugins: [swc(external)],
231
151
  onwarn: () => null
232
152
  }, options.input || {});
233
- const bundle = await (0, import_rollup.rollup)(input);
234
- const dependencies = Object.create(null);
235
- for (const m of ((_a = bundle.cache) == null ? void 0 : _a.modules) || [])
153
+ const bundle2 = await (0, import_rollup.rollup)(input);
154
+ const dependencies = /* @__PURE__ */ Object.create(null);
155
+ for (const m of ((_a = bundle2.cache) == null ? void 0 : _a.modules) || [])
236
156
  for (const d of m.dependencies)
237
- if (!d.startsWith("/") && !dependencies[d] && !NODE_PACKAGES.includes(d))
157
+ if (!d.startsWith("/") && !dependencies[d] && !import_ts_transform.NodeBuiltinModules.includes(d))
238
158
  dependencies[d] = "*";
239
159
  const output = (0, import_deep_merge2.deepMerge)({
240
160
  file: filename + ".tmp.js",
241
161
  format: "cjs",
242
162
  exports: "auto"
243
163
  }, options.output || {});
244
- await bundle.write(output);
245
- const result = Object.create(null);
164
+ await bundle2.write(output);
165
+ const result = /* @__PURE__ */ Object.create(null);
246
166
  result.dependencies = dependencies;
247
167
  result.module = require(output.file);
248
168
  if (options.tmp)
249
169
  (0, import_fs2.unlinkSync)(output.file);
250
170
  if (options.modules) {
251
- const modules = Object.create(null);
171
+ const modules = /* @__PURE__ */ Object.create(null);
252
172
  Object.keys(dependencies).map((d) => findModule(modules, d, options.modules));
253
173
  if (options.modules.additions)
254
174
  options.modules.additions.map((d) => findModule(modules, d, options.modules));
package/dist/index.mjs CHANGED
@@ -66,69 +66,7 @@ import {
66
66
  sep as sep2,
67
67
  dirname as dirname2
68
68
  } from "path";
69
- import resolve from "@rollup/plugin-node-resolve";
70
- import { transform } from "@swc/core";
71
- var FAAS_PACKAGES = [
72
- "@faasjs/ant-design",
73
- "@faasjs/aws",
74
- "@faasjs/browser",
75
- "@faasjs/cli",
76
- "@faasjs/cloud_function",
77
- "create-faas-app",
78
- "@faasjs/deep_merge",
79
- "@faasjs/deployer",
80
- "@faasjs/eslint-config-recommended",
81
- "@faasjs/eslint-config-vue",
82
- "faasjs",
83
- "@faasjs/func",
84
- "@faasjs/graphql-server",
85
- "@faasjs/http",
86
- "@faasjs/knex",
87
- "@faasjs/load",
88
- "@faasjs/logger",
89
- "@faasjs/react",
90
- "@faasjs/redis",
91
- "@faasjs/request",
92
- "@faasjs/server",
93
- "@faasjs/tencentcloud",
94
- "@faasjs/test",
95
- "@faasjs/vue-plugin"
96
- ];
97
- var NODE_PACKAGES = [
98
- "async_hooks",
99
- "child_process",
100
- "cluster",
101
- "crypto",
102
- "dns",
103
- "events",
104
- "fs",
105
- "http",
106
- "http2",
107
- "https",
108
- "inspector",
109
- "net",
110
- "os",
111
- "path",
112
- "perf_hooks",
113
- "process",
114
- "querystring",
115
- "readline",
116
- "repl",
117
- "stream",
118
- "string_decoder",
119
- "tls",
120
- "trace_events",
121
- "tty",
122
- "dgram",
123
- "udp4",
124
- "url",
125
- "util",
126
- "v8",
127
- "vm",
128
- "wasi",
129
- "worker_threads",
130
- "zlib"
131
- ];
69
+ import { bundle, NodeBuiltinModules } from "@faasjs/ts-transform";
132
70
  function resolveModuleBasePath(moduleName) {
133
71
  const moduleMainFilePath = __require.resolve(moduleName);
134
72
  const moduleNameParts = moduleName.split("/");
@@ -175,61 +113,48 @@ function findModule(list, key, options = { excludes: [] }) {
175
113
  }
176
114
  deps.map((d) => findModule(list, d, options));
177
115
  }
178
- function swc(options) {
116
+ function swc(externalModules) {
179
117
  return {
180
118
  name: "swc",
181
119
  async transform(code, filename) {
182
- options.filename = filename;
183
- return transform(code, options);
120
+ return bundle({
121
+ filename,
122
+ externalModules
123
+ });
184
124
  }
185
125
  };
186
126
  }
187
- async function loadTs(filename, options = Object.create(null)) {
127
+ async function loadTs(filename, options = /* @__PURE__ */ Object.create(null)) {
188
128
  var _a;
189
129
  const PackageJSON = __require(`${process.cwd()}/package.json`);
190
- const external = PackageJSON.dependencies ? FAAS_PACKAGES.concat(Object.keys(PackageJSON.dependencies)) : FAAS_PACKAGES;
130
+ const external = PackageJSON.dependencies ? Object.keys(PackageJSON.dependencies) : [];
191
131
  if (options.modules && options.modules.excludes == null)
192
132
  options.modules.excludes = [];
193
133
  const input = deepMerge2({
194
134
  input: filename,
195
135
  external,
196
- plugins: [
197
- resolve({
198
- extensions: [
199
- ".ts",
200
- ".tsx",
201
- ".js",
202
- ".jsx"
203
- ]
204
- }),
205
- swc({
206
- jsc: {
207
- parser: { syntax: "typescript" },
208
- target: "es2019"
209
- }
210
- })
211
- ],
136
+ plugins: [swc(external)],
212
137
  onwarn: () => null
213
138
  }, options.input || {});
214
- const bundle = await rollup(input);
215
- const dependencies = Object.create(null);
216
- for (const m of ((_a = bundle.cache) == null ? void 0 : _a.modules) || [])
139
+ const bundle2 = await rollup(input);
140
+ const dependencies = /* @__PURE__ */ Object.create(null);
141
+ for (const m of ((_a = bundle2.cache) == null ? void 0 : _a.modules) || [])
217
142
  for (const d of m.dependencies)
218
- if (!d.startsWith("/") && !dependencies[d] && !NODE_PACKAGES.includes(d))
143
+ if (!d.startsWith("/") && !dependencies[d] && !NodeBuiltinModules.includes(d))
219
144
  dependencies[d] = "*";
220
145
  const output = deepMerge2({
221
146
  file: filename + ".tmp.js",
222
147
  format: "cjs",
223
148
  exports: "auto"
224
149
  }, options.output || {});
225
- await bundle.write(output);
226
- const result = Object.create(null);
150
+ await bundle2.write(output);
151
+ const result = /* @__PURE__ */ Object.create(null);
227
152
  result.dependencies = dependencies;
228
153
  result.module = __require(output.file);
229
154
  if (options.tmp)
230
155
  unlinkSync(output.file);
231
156
  if (options.modules) {
232
- const modules = Object.create(null);
157
+ const modules = /* @__PURE__ */ Object.create(null);
233
158
  Object.keys(dependencies).map((d) => findModule(modules, d, options.modules));
234
159
  if (options.modules.additions)
235
160
  options.modules.additions.map((d) => findModule(modules, d, options.modules));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/load",
3
- "version": "0.0.2-beta.324",
3
+ "version": "0.0.2-beta.328",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -16,16 +16,16 @@
16
16
  },
17
17
  "funding": "https://github.com/sponsors/faasjs",
18
18
  "scripts": {
19
- "build": "rm -rf ./dist && tsup-node src/index.ts --format esm,cjs --dts"
19
+ "build": "tsup-node src/index.ts --format esm,cjs",
20
+ "build:types": "tsup-node src/index.ts --dts-only"
20
21
  },
21
22
  "files": [
22
23
  "dist"
23
24
  ],
24
25
  "peerDependencies": {
25
- "@faasjs/deep_merge": "^0.0.2-beta.324",
26
- "@faasjs/func": "^0.0.2-beta.324",
27
- "@rollup/plugin-node-resolve": "*",
28
- "@swc/core": "*",
26
+ "@faasjs/deep_merge": "^0.0.2-beta.328",
27
+ "@faasjs/func": "^0.0.2-beta.328",
28
+ "@faasjs/ts-transform": "^0.0.2-beta.328",
29
29
  "js-yaml": "*",
30
30
  "rollup": "*"
31
31
  },
@@ -36,6 +36,5 @@
36
36
  },
37
37
  "engines": {
38
38
  "npm": ">=8.0.0"
39
- },
40
- "gitHead": "4a9f699171ad7e20d922e68b74418d1ec5b7d016"
39
+ }
41
40
  }