@umijs/bundler-utils 4.0.0-beta.7 → 4.0.0-rc.2

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.
@@ -0,0 +1,50 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
+
3
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
4
+
5
+ const babel = require("./babel-core");
6
+
7
+ const handleMessage = require("./handle-message");
8
+
9
+ const {
10
+ parentPort
11
+ } = require("worker_threads");
12
+
13
+ parentPort.addListener("message", function () {
14
+ var _ref = _asyncToGenerator(function* ({
15
+ signal,
16
+ port,
17
+ action,
18
+ payload
19
+ }) {
20
+ let response;
21
+
22
+ try {
23
+ if (babel.init) yield babel.init;
24
+ response = {
25
+ result: yield handleMessage(action, payload)
26
+ };
27
+ } catch (error) {
28
+ response = {
29
+ error,
30
+ errorData: Object.assign({}, error)
31
+ };
32
+ }
33
+
34
+ try {
35
+ port.postMessage(response);
36
+ } catch (_unused) {
37
+ port.postMessage({
38
+ error: new Error("Cannot serialize worker response")
39
+ });
40
+ } finally {
41
+ port.close();
42
+ Atomics.store(signal, 0, 1);
43
+ Atomics.notify(signal, 0);
44
+ }
45
+ });
46
+
47
+ return function (_x) {
48
+ return _ref.apply(this, arguments);
49
+ };
50
+ }());
package/dist/index.d.ts CHANGED
@@ -1,2 +1,9 @@
1
- declare const _default: () => string;
2
- export default _default;
1
+ export declare function parseModule(opts: {
2
+ content: string;
3
+ path: string;
4
+ }): Promise<readonly [imports: readonly import("@umijs/bundler-utils/compiled/es-module-lexer").ImportSpecifier[], exports: readonly string[], facade: boolean]>;
5
+ export declare function parseModuleSync(opts: {
6
+ content: string;
7
+ path: string;
8
+ }): readonly [imports: readonly import("@umijs/bundler-utils/compiled/es-module-lexer").ImportSpecifier[], exports: readonly string[], facade: boolean];
9
+ export declare function isDepPath(path: string): boolean;
package/dist/index.js CHANGED
@@ -1,5 +1,40 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = () => {
4
- return '@umijs/bundler-utils';
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
5
10
  };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.isDepPath = exports.parseModuleSync = exports.parseModule = void 0;
13
+ const es_module_lexer_1 = require("@umijs/bundler-utils/compiled/es-module-lexer");
14
+ const esbuild_1 = require("@umijs/bundler-utils/compiled/esbuild");
15
+ const utils_1 = require("@umijs/utils");
16
+ const path_1 = require("path");
17
+ function parseModule(opts) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ yield es_module_lexer_1.init;
20
+ return parseModuleSync(opts);
21
+ });
22
+ }
23
+ exports.parseModule = parseModule;
24
+ function parseModuleSync(opts) {
25
+ let content = opts.content;
26
+ if (opts.path.endsWith('.tsx') || opts.path.endsWith('.jsx')) {
27
+ content = (0, esbuild_1.transformSync)(content, {
28
+ loader: (0, path_1.extname)(opts.path).slice(1),
29
+ format: 'esm',
30
+ }).code;
31
+ }
32
+ return (0, es_module_lexer_1.parse)(content);
33
+ }
34
+ exports.parseModuleSync = parseModuleSync;
35
+ function isDepPath(path) {
36
+ const umiMonorepoPaths = ['umi/packages/', 'umi-next/packages/'];
37
+ return (path.includes('node_modules') ||
38
+ umiMonorepoPaths.some((p) => (0, utils_1.winPath)(path).includes(p)));
39
+ }
40
+ exports.isDepPath = isDepPath;
package/package.json CHANGED
@@ -1,6 +1,13 @@
1
1
  {
2
2
  "name": "@umijs/bundler-utils",
3
- "version": "4.0.0-beta.7",
3
+ "version": "4.0.0-rc.2",
4
+ "homepage": "https://github.com/umijs/umi-next/tree/master/packages/bundler-utils#readme",
5
+ "bugs": "https://github.com/umijs/umi-next/issues",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/umijs/umi-next"
9
+ },
10
+ "license": "MIT",
4
11
  "main": "dist/index.js",
5
12
  "types": "dist/index.d.ts",
6
13
  "files": [
@@ -12,52 +19,46 @@
12
19
  "build:deps": "pnpm esno ../../scripts/bundleDeps.ts",
13
20
  "dev": "pnpm build -- --watch"
14
21
  },
15
- "repository": {
16
- "type": "git",
17
- "url": "https://github.com/umijs/umi-next"
18
- },
19
- "authors": [
20
- "chencheng <sorrycc@gmail.com> (https://github.com/sorrycc)"
21
- ],
22
- "license": "MIT",
23
- "bugs": "https://github.com/umijs/umi-next/issues",
24
- "homepage": "https://github.com/umijs/umi-next/tree/master/packages/bundler-utils#readme",
25
- "publishConfig": {
26
- "access": "public"
27
- },
28
22
  "dependencies": {
29
- "@umijs/utils": "4.0.0-beta.7",
30
- "esbuild": "0.13.11"
23
+ "@umijs/utils": "4.0.0-rc.2",
24
+ "esbuild": "0.14.22"
31
25
  },
32
26
  "devDependencies": {
33
- "@babel/code-frame": "7.16.0",
34
- "@babel/core": "7.16.0",
35
- "@babel/generator": "7.16.0",
36
- "@babel/parser": "7.16.0",
37
- "@babel/plugin-proposal-decorators": "7.16.0",
38
- "@babel/plugin-proposal-do-expressions": "7.16.0",
39
- "@babel/plugin-proposal-export-default-from": "7.16.0",
40
- "@babel/plugin-proposal-export-namespace-from": "7.16.0",
41
- "@babel/plugin-proposal-function-bind": "7.16.0",
42
- "@babel/plugin-proposal-partial-application": "7.16.0",
43
- "@babel/plugin-proposal-pipeline-operator": "7.16.0",
44
- "@babel/plugin-proposal-record-and-tuple": "7.16.0",
45
- "@babel/plugin-transform-runtime": "7.16.0",
46
- "@babel/preset-env": "7.16.0",
47
- "@babel/preset-react": "7.16.0",
48
- "@babel/preset-typescript": "7.16.0",
49
- "@babel/register": "7.16.0",
50
- "@babel/template": "7.16.0",
51
- "@babel/traverse": "7.16.0",
52
- "@babel/types": "7.16.0",
27
+ "@babel/code-frame": "7.16.7",
28
+ "@babel/core": "7.17.5",
29
+ "@babel/generator": "7.17.3",
30
+ "@babel/helper-module-imports": "7.16.7",
31
+ "@babel/parser": "7.17.3",
32
+ "@babel/plugin-proposal-decorators": "7.17.2",
33
+ "@babel/plugin-proposal-do-expressions": "7.16.7",
34
+ "@babel/plugin-proposal-export-default-from": "7.16.7",
35
+ "@babel/plugin-proposal-export-namespace-from": "7.16.7",
36
+ "@babel/plugin-proposal-function-bind": "7.16.7",
37
+ "@babel/plugin-proposal-partial-application": "7.16.7",
38
+ "@babel/plugin-proposal-pipeline-operator": "7.16.7",
39
+ "@babel/plugin-proposal-record-and-tuple": "7.16.7",
40
+ "@babel/plugin-transform-runtime": "7.17.0",
41
+ "@babel/preset-env": "7.16.11",
42
+ "@babel/preset-react": "7.16.7",
43
+ "@babel/preset-typescript": "7.16.7",
44
+ "@babel/register": "7.17.0",
45
+ "@babel/template": "7.16.7",
46
+ "@babel/traverse": "7.17.3",
47
+ "@babel/types": "7.17.0",
53
48
  "@types/babel__code-frame": "7.0.3",
54
- "@types/babel__generator": "7.6.3",
49
+ "@types/babel__generator": "7.6.4",
55
50
  "@types/babel__parser": "7.1.1",
56
51
  "@types/babel__template": "7.4.1",
57
52
  "@types/babel__traverse": "7.14.2",
58
53
  "cjs-module-lexer": "1.2.2",
59
54
  "es-module-lexer": "0.9.3"
60
55
  },
56
+ "publishConfig": {
57
+ "access": "public"
58
+ },
59
+ "authors": [
60
+ "chencheng <sorrycc@gmail.com> (https://github.com/sorrycc)"
61
+ ],
61
62
  "compiledConfig": {
62
63
  "deps": [
63
64
  "cjs-module-lexer",