@modern-js/server-utils 1.2.2 → 1.2.5

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/.eslintrc.js ADDED
@@ -0,0 +1,8 @@
1
+ module.exports = {
2
+ root: true,
3
+ extends: ['@modern-js'],
4
+ parserOptions: {
5
+ tsconfigRootDir: __dirname,
6
+ project: ['./tsconfig.json'],
7
+ },
8
+ };
package/CHANGELOG.md CHANGED
@@ -1,5 +1,52 @@
1
1
  # @modern-js/server-utils
2
2
 
3
+ ## 1.2.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 0e0537005: fix: unlock @babel/core version
8
+ - 69a728375: fix: remove exports.jsnext:source after publish
9
+ - Updated dependencies [cd7346b0d]
10
+ - Updated dependencies [0e0537005]
11
+ - Updated dependencies [69a728375]
12
+ - @modern-js/utils@1.7.2
13
+ - @modern-js/babel-preset-lib@1.2.4
14
+
15
+ ## 1.2.4
16
+
17
+ ### Patch Changes
18
+
19
+ - 592edabc: feat: prebundle url-join,mime-types,json5,fast-glob,globby,ora,inquirer
20
+ - Updated dependencies [2d155c4c]
21
+ - Updated dependencies [123e432d]
22
+ - Updated dependencies [e5a9b26d]
23
+ - Updated dependencies [0b26b93b]
24
+ - Updated dependencies [123e432d]
25
+ - Updated dependencies [f9f66ef9]
26
+ - Updated dependencies [592edabc]
27
+ - Updated dependencies [895fa0ff]
28
+ - Updated dependencies [3578913e]
29
+ - Updated dependencies [1c3beab3]
30
+ - @modern-js/utils@1.6.0
31
+
32
+ ## 1.2.3
33
+
34
+ ### Patch Changes
35
+
36
+ - 6cffe99d: chore:
37
+ remove react eslint rules for `modern-js` rule set.
38
+ add .eslintrc for each package to speed up linting
39
+ - 04ae5262: chore: bump @modern-js/utils to v1.4.1 in dependencies
40
+ - 60f7d8bf: feat: add tests dir to npmignore
41
+ - Updated dependencies [b8599d09]
42
+ - Updated dependencies [6cffe99d]
43
+ - Updated dependencies [04ae5262]
44
+ - Updated dependencies [60f7d8bf]
45
+ - Updated dependencies [3bf4f8b0]
46
+ - @modern-js/utils@1.5.0
47
+ - @modern-js/babel-preset-lib@1.2.3
48
+ - @modern-js/plugin@1.3.3
49
+
3
50
  ## 1.2.2
4
51
 
5
52
  ### Patch Changes
@@ -5,8 +5,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
5
5
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
6
 
7
7
  import { getBabelChain } from '@modern-js/babel-preset-lib';
8
- import { applyOptionsChain, fs, getAlias } from '@modern-js/utils';
9
- import json5 from 'json5';
8
+ import { fs, json5, getAlias, applyOptionsChain } from '@modern-js/utils';
10
9
  export * from '@babel/core';
11
10
  export const readTsConfig = (tsconfigPath, noExistReturn = null) => {
12
11
  // 如果不存在,则返回 noExistReturn
@@ -15,8 +15,6 @@ var _babelPresetLib = require("@modern-js/babel-preset-lib");
15
15
 
16
16
  var _utils = require("@modern-js/utils");
17
17
 
18
- var _json = _interopRequireDefault(require("json5"));
19
-
20
18
  var _core = require("@babel/core");
21
19
 
22
20
  Object.keys(_core).forEach(function (key) {
@@ -31,8 +29,6 @@ Object.keys(_core).forEach(function (key) {
31
29
  });
32
30
  });
33
31
 
34
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35
-
36
32
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
37
33
 
38
34
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -47,7 +43,7 @@ const readTsConfig = (tsconfigPath, noExistReturn = null) => {
47
43
 
48
44
  const content = _utils.fs.readFileSync(tsconfigPath, 'utf-8');
49
45
 
50
- return _json.default.parse(content);
46
+ return _utils.json5.parse(content);
51
47
  };
52
48
 
53
49
  exports.readTsConfig = readTsConfig;
@@ -5,8 +5,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
5
5
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
6
 
7
7
  import { getBabelChain } from '@modern-js/babel-preset-lib';
8
- import { applyOptionsChain, fs, getAlias } from '@modern-js/utils';
9
- import json5 from 'json5';
8
+ import { fs, json5, getAlias, applyOptionsChain } from '@modern-js/utils';
10
9
  export * from '@babel/core';
11
10
  export var readTsConfig = function readTsConfig(tsconfigPath) {
12
11
  var noExistReturn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.2.2",
14
+ "version": "1.2.5",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -29,21 +29,20 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@babel/compat-data": "^7.15.0",
32
- "@babel/core": "7.16.7",
32
+ "@babel/core": "^7.17.0",
33
33
  "@babel/plugin-proposal-class-properties": "^7.14.5",
34
34
  "@babel/plugin-proposal-decorators": "^7.15.4",
35
35
  "@babel/preset-env": "^7.15.0",
36
36
  "@babel/preset-typescript": "^7.15.0",
37
37
  "@babel/runtime": "^7",
38
- "@modern-js/babel-preset-lib": "^1.2.1",
39
- "@modern-js/plugin": "^1.2.1",
40
- "@modern-js/utils": "^1.3.7",
38
+ "@modern-js/babel-preset-lib": "^1.2.4",
39
+ "@modern-js/plugin": "^1.3.3",
40
+ "@modern-js/utils": "^1.7.2",
41
41
  "babel-plugin-module-resolver": "^4.1.0",
42
- "babel-plugin-transform-typescript-metadata": "^0.3.2",
43
- "json5": "^2.2.0"
42
+ "babel-plugin-transform-typescript-metadata": "^0.3.2"
44
43
  },
45
44
  "devDependencies": {
46
- "@modern-js/core": "1.6.1",
45
+ "@modern-js/core": "1.10.1",
47
46
  "@types/babel__core": "^7.1.15",
48
47
  "@types/jest": "^26",
49
48
  "@types/node": "^14",
@@ -1,6 +0,0 @@
1
- module.exports = {
2
- extends: ['@modern-js'],
3
- parserOptions: {
4
- project: require.resolve('./tsconfig.json'),
5
- },
6
- };
@@ -1,174 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`babel resolveBabelConfig 1`] = `
4
- Object {
5
- "plugins": Array [
6
- Array [
7
- "/babel-plugin-macros/dist/index.js",
8
- Object {
9
- "twin": Object {
10
- "preset": "styled-components",
11
- },
12
- },
13
- ],
14
- Array [
15
- "/babel-plugin-import/lib/index.js",
16
- Object {
17
- "libraryDirectory": "es",
18
- "libraryName": "antd",
19
- "style": true,
20
- },
21
- "import-antd",
22
- ],
23
- Array [
24
- "/babel-plugin-lodash/lib/index.js",
25
- Object {
26
- "id": Array [
27
- "lodash",
28
- "ramda",
29
- ],
30
- },
31
- ],
32
- Array [
33
- "/@babel/plugin-proposal-decorators/lib/index.js",
34
- Object {
35
- "legacy": true,
36
- },
37
- ],
38
- Array [
39
- "/@babel/plugin-proposal-class-properties/lib/index.js",
40
- Object {
41
- "loose": true,
42
- },
43
- ],
44
- Array [
45
- "/@babel/plugin-proposal-private-methods/lib/index.js",
46
- Object {
47
- "loose": true,
48
- },
49
- ],
50
- Array [
51
- "/@babel/plugin-proposal-private-property-in-object/lib/index.js",
52
- Object {
53
- "loose": true,
54
- },
55
- ],
56
- Array [
57
- "/@babel/plugin-proposal-object-rest-spread/lib/index.js",
58
- Object {
59
- "useBuiltIns": true,
60
- },
61
- ],
62
- Array [
63
- "/@babel/plugin-transform-runtime/lib/index.js",
64
- Object {
65
- "corejs": false,
66
- "helpers": false,
67
- "regenerator": true,
68
- "useESModules": false,
69
- "version": "7.16.7",
70
- },
71
- ],
72
- Array [
73
- "/babel-plugin-transform-react-remove-prop-types/lib/index.js",
74
- Object {
75
- "removeImport": true,
76
- },
77
- ],
78
- Array [
79
- "/@babel/plugin-proposal-function-bind/lib/index.js",
80
- ],
81
- Array [
82
- "/@babel/plugin-proposal-export-default-from/lib/index.js",
83
- ],
84
- Array [
85
- "/@babel/plugin-proposal-export-namespace-from/lib/index.js",
86
- ],
87
- Array [
88
- "/@babel/plugin-proposal-optional-chaining/lib/index.js",
89
- ],
90
- Array [
91
- "/@babel/plugin-proposal-numeric-separator/lib/index.js",
92
- ],
93
- Array [
94
- "/@babel/plugin-proposal-pipeline-operator/lib/index.js",
95
- Object {
96
- "proposal": "minimal",
97
- },
98
- ],
99
- Array [
100
- "/@babel/plugin-proposal-partial-application/lib/index.js",
101
- ],
102
- Array [
103
- "/@babel/plugin-proposal-nullish-coalescing-operator/lib/index.js",
104
- ],
105
- Array [
106
- "/babel-plugin-styled-components/lib/index.js",
107
- Object {},
108
- "styled-components",
109
- ],
110
- Array [
111
- "/babel-plugin-transform-inline-environment-variables/lib/index.js",
112
- Object {
113
- "include": Array [],
114
- },
115
- ],
116
- Array [
117
- "/babel-plugin-module-resolver/lib/index.js",
118
- Object {
119
- "alias": Object {
120
- "@/*": Array [
121
- "./src/*",
122
- ],
123
- },
124
- "extensions": Array [
125
- ".ts",
126
- ".tsx",
127
- ".js",
128
- ".jsx",
129
- ".es",
130
- ".es6",
131
- ".mjs",
132
- ],
133
- "resolvePath": [Function],
134
- "root": "/packages/server/utils/tests/fixtures/",
135
- },
136
- ],
137
- Array [
138
- "/babel-plugin-transform-typescript-metadata/lib/plugin.js",
139
- ],
140
- ],
141
- "presets": Array [
142
- Array [
143
- "/@babel/preset-env/lib/index.js",
144
- Object {
145
- "bugfixes": true,
146
- "modules": "commonjs",
147
- "shippedProposals": false,
148
- "targets": Array [
149
- "chrome > 61",
150
- "edge > 16",
151
- "firefox > 60",
152
- "safari > 11",
153
- "ios_saf > 11",
154
- ],
155
- },
156
- ],
157
- Array [
158
- "/@babel/preset-react/lib/index.js",
159
- Object {
160
- "runtime": "automatic",
161
- },
162
- ],
163
- Array [
164
- "/@babel/preset-typescript/lib/index.js",
165
- Object {
166
- "allExtensions": true,
167
- "allowDeclareFields": true,
168
- "allowNamespaces": true,
169
- "isTSX": true,
170
- },
171
- ],
172
- ],
173
- }
174
- `;
@@ -1,40 +0,0 @@
1
- import path from 'path';
2
- import { resolveBabelConfig } from '../src';
3
- import { defaults } from './helpers';
4
-
5
- describe('babel', () => {
6
- it('resolveBabelConfig', () => {
7
- const pwd = path.resolve(__dirname, './fixtures');
8
- const tsconfigPath = path.resolve(
9
- __dirname,
10
- './fixtures/api/tsconfig.json',
11
- );
12
- const config = resolveBabelConfig(pwd, defaults as any, {
13
- type: 'commonjs',
14
- syntax: 'es6+',
15
- tsconfigPath,
16
- });
17
-
18
- const root = path.resolve(__dirname, '../../../../');
19
-
20
- expect.addSnapshotSerializer({
21
- test: val =>
22
- typeof val === 'string' &&
23
- (val.includes('modern.js') ||
24
- val.includes('node_modules') ||
25
- val.includes(root)),
26
- print: val =>
27
- // eslint-disable-next-line no-nested-ternary
28
- typeof val === 'string'
29
- ? // eslint-disable-next-line no-nested-ternary
30
- val.includes('node_modules')
31
- ? `"${val.replace(/.+node_modules/, '').replace(/\\/g, '/')}"`
32
- : val.includes('modern.js')
33
- ? `"${val.replace(/.+modern\.js/, '').replace(/\\/g, '/')}"`
34
- : `"${val.replace(root, '').replace(/\\/g, '/')}"`
35
- : (val as string),
36
- });
37
-
38
- expect(config).toMatchSnapshot();
39
- });
40
- });
@@ -1,5 +0,0 @@
1
- import { hook } from '../../../src';
2
-
3
- export default hook(({ addMiddleware }) => {
4
- addMiddleware('@koa/api');
5
- });
@@ -1,14 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "declaration": false,
4
- "jsx": "preserve",
5
- "baseUrl": "./",
6
- "isolatedModules": true,
7
- "experimentalDecorators": true,
8
- "esModuleInterop": true,
9
- "paths": {
10
- "@/*": ["./src/*"]
11
- }
12
- },
13
- "include": ["src", "api", "server", "electron"]
14
- }
@@ -1,5 +0,0 @@
1
- import { hook } from '../../../src';
2
-
3
- export default hook(({ addMiddleware }) => {
4
- addMiddleware('@koa/web');
5
- });
package/tests/helpers.ts DELETED
@@ -1,100 +0,0 @@
1
- const sourceDefaults = {
2
- entries: undefined,
3
- disableDefaultEntries: false,
4
- entriesDir: './src',
5
- configDir: './config',
6
- apiDir: './api',
7
- envVars: [],
8
- globalVars: undefined,
9
- alias: undefined,
10
- moduleScopes: undefined,
11
- include: [],
12
- };
13
-
14
- const outputDefaults = {
15
- assetPrefix: '/',
16
- htmlPath: 'html',
17
- jsPath: 'static/js',
18
- cssPath: 'static/css',
19
- mediaPath: 'static/media',
20
- path: 'dist',
21
- title: '',
22
- titleByEntries: undefined,
23
- meta: {
24
- charset: { charset: 'utf-8' },
25
- viewport:
26
- 'width=device-width, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no',
27
- 'http-equiv': { 'http-equiv': 'x-ua-compatible', content: 'ie=edge' },
28
- renderer: 'webkit',
29
- layoutmode: 'standard',
30
- imagemode: 'force',
31
- 'wap-font-scale': 'no',
32
- 'format-detection': 'telephone=no',
33
- },
34
- metaByEntries: undefined,
35
- inject: 'head',
36
- injectByEntries: undefined,
37
- mountId: 'root',
38
- favicon: '',
39
- faviconByEntries: undefined,
40
- copy: undefined,
41
- scriptExt: undefined,
42
- disableHtmlFolder: false,
43
- disableCssModuleExtension: false,
44
- disableCssExtract: false,
45
- enableCssModuleTSDeclaration: false,
46
- disableMinimize: false,
47
- enableInlineStyles: false,
48
- enableInlineScripts: false,
49
- disableSourceMap: false,
50
- disableInlineRuntimeChunk: false,
51
- disableAssetsCache: false,
52
- enableLatestDecorators: false,
53
- polyfill: 'entry',
54
- dataUriLimit: 10000,
55
- templateParameters: {},
56
- templateParametersByEntries: undefined,
57
- cssModuleLocalIdentName: '[name]__[local]--[hash:base64:5]',
58
- enableModernMode: false,
59
- federation: undefined,
60
- disableNodePolyfill: false,
61
- enableTsLoader: false,
62
- };
63
-
64
- const serverDefaults = {
65
- routes: undefined,
66
- publicRoutes: undefined,
67
- ssr: undefined,
68
- ssrByEntries: undefined,
69
- baseUrl: '/',
70
- port: 8080,
71
- };
72
-
73
- const devDefaults = { assetPrefix: false };
74
-
75
- const deployDefaults = {
76
- microFrontend: false,
77
- domain: '',
78
- domainByEntries: undefined,
79
- };
80
-
81
- const toolsDefaults = {
82
- webpack: undefined,
83
- babel: undefined,
84
- postcss: undefined,
85
- autoprefixer: undefined,
86
- lodash: undefined,
87
- devServer: undefined,
88
- tsLoader: undefined,
89
- terser: undefined,
90
- minifyCss: undefined,
91
- };
92
-
93
- export const defaults = {
94
- source: sourceDefaults,
95
- output: outputDefaults,
96
- server: serverDefaults,
97
- dev: devDefaults,
98
- deploy: deployDefaults,
99
- tools: toolsDefaults,
100
- };
@@ -1,11 +0,0 @@
1
- {
2
- "extends": "@modern-js/tsconfig/base",
3
- "compilerOptions": {
4
- "declaration": false,
5
- "jsx": "preserve",
6
- "baseUrl": "./",
7
- "isolatedModules": true,
8
- "paths": {},
9
- "types": ["node", "jest"]
10
- }
11
- }