@modern-js/server-utils 2.0.0-beta.1 → 2.0.0-beta.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,93 @@
1
1
  # @modern-js/server-utils
2
2
 
3
+ ## 2.0.0-beta.3
4
+
5
+ ### Major Changes
6
+
7
+ - dda38c9c3e: chore: v2
8
+
9
+ ### Patch Changes
10
+
11
+ - 9b915e0c10: fix: tsconfig-paths plugin's new node use old node flag
12
+ fix: tsconfig-paths 插件转换的新节点使用旧节点的 flag
13
+ - d4e8e6f: fix: modernjs dev server can't start normaly
14
+ fix: modernjs dev 服务端不能正常启动
15
+ - a8642da58f: fix(server-utils): incorrect babel-compiler version
16
+
17
+ fix(server-utils): 修复引用错误的 babel-compiler 版本的问题
18
+
19
+ - c2bb0f1: chore(server-utils): using pre-bundled tsconfig-paths
20
+
21
+ chore(server-utils): 使用预打包的 tsconfig-paths 依赖
22
+
23
+ - 14b712da84: fix: use consistent alias type and default value across packages
24
+
25
+ fix: 在各个包中使用一致的 alias 类型定义和默认值
26
+
27
+ - Updated dependencies [6aca875]
28
+ - Updated dependencies [2e60319]
29
+ - Updated dependencies [92f0eade39]
30
+ - Updated dependencies [edd1cfb1af]
31
+ - Updated dependencies [cc971eabfc]
32
+ - Updated dependencies [5b9049f2e9]
33
+ - Updated dependencies [92004d1906]
34
+ - Updated dependencies [b8bbe036c7]
35
+ - Updated dependencies [d5a31df781]
36
+ - Updated dependencies [dda38c9c3e]
37
+ - Updated dependencies [3bbea92b2a]
38
+ - Updated dependencies [b710adb]
39
+ - Updated dependencies [f179749375]
40
+ - Updated dependencies [ea7cf06]
41
+ - Updated dependencies [bbe4c4a]
42
+ - Updated dependencies [e4558a0]
43
+ - Updated dependencies [abf3421a75]
44
+ - Updated dependencies [543be9558e]
45
+ - Updated dependencies [14b712da84]
46
+ - @modern-js/utils@2.0.0-beta.3
47
+ - @modern-js/plugin@2.0.0-beta.3
48
+ - @modern-js/babel-preset-lib@2.0.0-beta.3
49
+ - @modern-js/babel-compiler@2.0.0-beta.3
50
+
51
+ ## 2.0.0-beta.2
52
+
53
+ ### Major Changes
54
+
55
+ - dda38c9c3e: chore: v2
56
+
57
+ ### Patch Changes
58
+
59
+ - 9b915e0c10: fix: tsconfig-paths plugin's new node use old node flag
60
+ fix: tsconfig-paths 插件转换的新节点使用旧节点的 flag
61
+ - a8642da58f: fix(server-utils): incorrect babel-compiler version
62
+
63
+ fix(server-utils): 修复引用错误的 babel-compiler 版本的问题
64
+
65
+ - c2bb0f1: chore(server-utils): using pre-bundled tsconfig-paths
66
+
67
+ chore(server-utils): 使用预打包的 tsconfig-paths 依赖
68
+
69
+ - 14b712da84: fix: use consistent alias type and default value across packages
70
+
71
+ fix: 在各个包中使用一致的 alias 类型定义和默认值
72
+
73
+ - Updated dependencies [92f0ead]
74
+ - Updated dependencies [edd1cfb1af]
75
+ - Updated dependencies [cc971eabfc]
76
+ - Updated dependencies [5b9049f2e9]
77
+ - Updated dependencies [92004d1]
78
+ - Updated dependencies [b8bbe036c7]
79
+ - Updated dependencies [d5a31df781]
80
+ - Updated dependencies [dda38c9c3e]
81
+ - Updated dependencies [3bbea92b2a]
82
+ - Updated dependencies [f179749]
83
+ - Updated dependencies [abf3421a75]
84
+ - Updated dependencies [543be9558e]
85
+ - Updated dependencies [14b712da84]
86
+ - @modern-js/utils@2.0.0-beta.2
87
+ - @modern-js/plugin@2.0.0-beta.2
88
+ - @modern-js/babel-preset-lib@2.0.0-beta.2
89
+ - @modern-js/babel-compiler@2.0.0-beta.2
90
+
3
91
  ## 2.0.0-beta.1
4
92
 
5
93
  ### Major Changes
@@ -25,16 +25,17 @@ export const getBabelConfig = (libPresetOption, syntaxOption) => {
25
25
  sourceType: 'unambiguous'
26
26
  }, chain.toJSON());
27
27
  };
28
- export const resolveBabelConfig = (appDirectory, config, option
29
- // FIXME: babel type can't pass type checking
30
- ) => {
28
+ export const resolveBabelConfig = (appDirectory, config, option) => {
31
29
  const {
32
- envVars,
33
30
  globalVars,
34
31
  alias,
35
- babelConfig
32
+ babelConfig,
33
+ define
36
34
  } = config;
37
-
35
+ const globalDefineVars = define && Object.entries(define).reduce((object, [key, value]) => {
36
+ object[key] = JSON.stringify(value);
37
+ return object;
38
+ }, {});
38
39
  // alias config
39
40
  const aliasConfig = getAliasConfig(alias, _objectSpread({
40
41
  appDirectory
@@ -46,8 +47,8 @@ export const resolveBabelConfig = (appDirectory, config, option
46
47
  enableReactPreset: true,
47
48
  enableTypescriptPreset: true,
48
49
  alias: aliasConfig,
49
- envVars,
50
- globalVars
50
+ envVars: [],
51
+ globalVars: _objectSpread(_objectSpread({}, globalVars), globalDefineVars)
51
52
  }, {
52
53
  type: option.type,
53
54
  syntax: option.syntax
@@ -1,7 +1,7 @@
1
1
  import * as os from 'os';
2
2
  import path, { dirname, posix } from 'path';
3
3
  import * as ts from 'typescript';
4
- import { createMatchPath } from 'tsconfig-paths';
4
+ import { createMatchPath } from '@modern-js/utils/tsconfig-paths';
5
5
  const isRegExpKey = str => {
6
6
  return str.startsWith('^') || str.endsWith('$');
7
7
  };
@@ -54,16 +54,17 @@ const getBabelConfig = (libPresetOption, syntaxOption) => {
54
54
  }, chain.toJSON());
55
55
  };
56
56
  exports.getBabelConfig = getBabelConfig;
57
- const resolveBabelConfig = (appDirectory, config, option
58
- // FIXME: babel type can't pass type checking
59
- ) => {
57
+ const resolveBabelConfig = (appDirectory, config, option) => {
60
58
  const {
61
- envVars,
62
59
  globalVars,
63
60
  alias,
64
- babelConfig
61
+ babelConfig,
62
+ define
65
63
  } = config;
66
-
64
+ const globalDefineVars = define && Object.entries(define).reduce((object, [key, value]) => {
65
+ object[key] = JSON.stringify(value);
66
+ return object;
67
+ }, {});
67
68
  // alias config
68
69
  const aliasConfig = (0, _utils.getAliasConfig)(alias, _objectSpread({
69
70
  appDirectory
@@ -75,8 +76,8 @@ const resolveBabelConfig = (appDirectory, config, option
75
76
  enableReactPreset: true,
76
77
  enableTypescriptPreset: true,
77
78
  alias: aliasConfig,
78
- envVars,
79
- globalVars
79
+ envVars: [],
80
+ globalVars: _objectSpread(_objectSpread({}, globalVars), globalDefineVars)
80
81
  }, {
81
82
  type: option.type,
82
83
  syntax: option.syntax
@@ -7,7 +7,7 @@ exports.tsconfigPathsBeforeHookFactory = tsconfigPathsBeforeHookFactory;
7
7
  var os = _interopRequireWildcard(require("os"));
8
8
  var _path = _interopRequireWildcard(require("path"));
9
9
  var ts = _interopRequireWildcard(require("typescript"));
10
- var _tsconfigPaths = require("tsconfig-paths");
10
+ var _tsconfigPaths = require("@modern-js/utils/tsconfig-paths");
11
11
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
12
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
13
  const isRegExpKey = str => {
@@ -1,5 +1,6 @@
1
1
  import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
4
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
5
  import * as path from 'path';
5
6
  import { getBabelChain, applyUserBabelConfig } from '@modern-js/babel-preset-lib';
@@ -26,14 +27,18 @@ export var getBabelConfig = function getBabelConfig(libPresetOption, syntaxOptio
26
27
  sourceType: 'unambiguous'
27
28
  }, chain.toJSON());
28
29
  };
29
- export var resolveBabelConfig = function resolveBabelConfig(appDirectory, config, option
30
- // FIXME: babel type can't pass type checking
31
- ) {
32
- var envVars = config.envVars,
33
- globalVars = config.globalVars,
30
+ export var resolveBabelConfig = function resolveBabelConfig(appDirectory, config, option) {
31
+ var globalVars = config.globalVars,
34
32
  alias = config.alias,
35
- babelConfig = config.babelConfig;
36
-
33
+ babelConfig = config.babelConfig,
34
+ define = config.define;
35
+ var globalDefineVars = define && Object.entries(define).reduce(function (object, _ref) {
36
+ var _ref2 = _slicedToArray(_ref, 2),
37
+ key = _ref2[0],
38
+ value = _ref2[1];
39
+ object[key] = JSON.stringify(value);
40
+ return object;
41
+ }, {});
37
42
  // alias config
38
43
  var aliasConfig = getAliasConfig(alias, _objectSpread({
39
44
  appDirectory: appDirectory
@@ -45,8 +50,8 @@ export var resolveBabelConfig = function resolveBabelConfig(appDirectory, config
45
50
  enableReactPreset: true,
46
51
  enableTypescriptPreset: true,
47
52
  alias: aliasConfig,
48
- envVars: envVars,
49
- globalVars: globalVars
53
+ envVars: [],
54
+ globalVars: _objectSpread(_objectSpread({}, globalVars), globalDefineVars)
50
55
  }, {
51
56
  type: option.type,
52
57
  syntax: option.syntax
@@ -68,7 +73,7 @@ export var resolveBabelConfig = function resolveBabelConfig(appDirectory, config
68
73
  return applyUserBabelConfig(internalBabelConfig, babelConfig);
69
74
  };
70
75
  export var compileByBabel = /*#__PURE__*/function () {
71
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(appDirectory, config, compileOptions) {
76
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(appDirectory, config, compileOptions) {
72
77
  var sourceDirs, distDir, tsconfigPath, results;
73
78
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
74
79
  while (1) {
@@ -77,7 +82,7 @@ export var compileByBabel = /*#__PURE__*/function () {
77
82
  sourceDirs = compileOptions.sourceDirs, distDir = compileOptions.distDir, tsconfigPath = compileOptions.tsconfigPath;
78
83
  _context2.next = 3;
79
84
  return Promise.all(sourceDirs.map( /*#__PURE__*/function () {
80
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(sourceDir) {
85
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(sourceDir) {
81
86
  var babelConfig, basename, targetDir;
82
87
  return _regeneratorRuntime().wrap(function _callee$(_context) {
83
88
  while (1) {
@@ -118,7 +123,7 @@ export var compileByBabel = /*#__PURE__*/function () {
118
123
  }, _callee);
119
124
  }));
120
125
  return function (_x4) {
121
- return _ref2.apply(this, arguments);
126
+ return _ref4.apply(this, arguments);
122
127
  };
123
128
  }()));
124
129
  case 3:
@@ -136,6 +141,6 @@ export var compileByBabel = /*#__PURE__*/function () {
136
141
  }, _callee2);
137
142
  }));
138
143
  return function compileByBabel(_x, _x2, _x3) {
139
- return _ref.apply(this, arguments);
144
+ return _ref3.apply(this, arguments);
140
145
  };
141
146
  }();
@@ -4,7 +4,7 @@ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIt
4
4
  import * as os from 'os';
5
5
  import path, { dirname, posix } from 'path';
6
6
  import * as ts from 'typescript';
7
- import { createMatchPath } from 'tsconfig-paths';
7
+ import { createMatchPath } from '@modern-js/utils/tsconfig-paths';
8
8
  var isRegExpKey = function isRegExpKey(str) {
9
9
  return str.startsWith('^') || str.endsWith('$');
10
10
  };
@@ -1,14 +1,14 @@
1
- import type { NormalizedConfig } from '@modern-js/core';
1
+ import type { SourceNormalizedConfig, ToolsNormalizedConfig } from '@modern-js/server-core';
2
2
  export interface Pattern {
3
3
  from: string;
4
4
  to: string;
5
5
  tsconfigPath?: string;
6
6
  }
7
7
  export interface IConfig {
8
- alias?: NormalizedConfig['source']['alias'];
9
- envVars?: NormalizedConfig['source']['envVars'];
10
- globalVars?: NormalizedConfig['source']['globalVars'];
11
- babelConfig?: NormalizedConfig['tools']['babel'];
8
+ alias?: SourceNormalizedConfig['alias'];
9
+ define?: SourceNormalizedConfig['define'];
10
+ globalVars?: SourceNormalizedConfig['globalVars'];
11
+ babelConfig?: ToolsNormalizedConfig['babel'];
12
12
  server: {
13
13
  compiler?: 'babel' | 'typescript';
14
14
  };
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.0.0-beta.1",
14
+ "version": "2.0.0-beta.3",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -37,11 +37,10 @@
37
37
  "@babel/runtime": "^7.18.0",
38
38
  "babel-plugin-module-resolver": "^4.1.0",
39
39
  "babel-plugin-transform-typescript-metadata": "^0.3.2",
40
- "tsconfig-paths": "3.14.1",
41
- "@modern-js/babel-compiler": "2.0.0-beta.1",
42
- "@modern-js/babel-preset-lib": "2.0.0-beta.1",
43
- "@modern-js/plugin": "2.0.0-beta.1",
44
- "@modern-js/utils": "2.0.0-beta.1"
40
+ "@modern-js/babel-compiler": "2.0.0-beta.3",
41
+ "@modern-js/babel-preset-lib": "2.0.0-beta.3",
42
+ "@modern-js/plugin": "2.0.0-beta.3",
43
+ "@modern-js/utils": "2.0.0-beta.3"
45
44
  },
46
45
  "devDependencies": {
47
46
  "@types/babel__core": "^7.1.15",
@@ -50,9 +49,9 @@
50
49
  "jest": "^27",
51
50
  "ts-jest": "^27.0.4",
52
51
  "typescript": "^4",
53
- "@modern-js/core": "2.0.0-beta.1",
54
- "@scripts/build": "2.0.0-beta.1",
55
- "@scripts/jest-config": "2.0.0-beta.1"
52
+ "@modern-js/server-core": "2.0.0-beta.3",
53
+ "@scripts/build": "2.0.0-beta.3",
54
+ "@scripts/jest-config": "2.0.0-beta.3"
56
55
  },
57
56
  "sideEffects": false,
58
57
  "publishConfig": {
@@ -60,9 +59,9 @@
60
59
  "access": "public"
61
60
  },
62
61
  "scripts": {
63
- "new": "modern new",
64
- "dev": "modern build --watch",
65
- "build": "modern build",
62
+ "new": "modern-lib new",
63
+ "dev": "modern-lib build --watch",
64
+ "build": "modern-lib build",
66
65
  "test": "jest --passWithNoTests"
67
66
  }
68
67
  }