@modern-js/plugin-server 1.15.1-beta.0 → 1.17.0

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,35 @@
1
1
  # @modern-js/plugin-server
2
2
 
3
+ ## 1.17.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [1b9176f]
8
+ - Updated dependencies [77d3a38]
9
+ - Updated dependencies [151329d]
10
+ - Updated dependencies [5af9472]
11
+ - Updated dependencies [6b6a534]
12
+ - Updated dependencies [6b43a2b]
13
+ - Updated dependencies [a7be124]
14
+ - Updated dependencies [31547b4]
15
+ - @modern-js/utils@1.17.0
16
+ - @modern-js/server-utils@1.17.0
17
+ - @modern-js/babel-compiler@1.17.0
18
+
19
+ ## 1.16.0
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies [641592f52]
24
+ - Updated dependencies [3904b30a5]
25
+ - Updated dependencies [1100dd58c]
26
+ - Updated dependencies [e04e6e76a]
27
+ - Updated dependencies [81c66e4a4]
28
+ - Updated dependencies [2c305b6f5]
29
+ - @modern-js/utils@1.16.0
30
+ - @modern-js/server-utils@1.16.0
31
+ - @modern-js/babel-compiler@1.16.0
32
+
3
33
  ## 1.15.0
4
34
 
5
35
  ### Patch Changes
@@ -1,47 +1,39 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
- import { compile } from '@modern-js/server-utils';
3
+ import { compiler } from '@modern-js/babel-compiler';
4
+ import { resolveBabelConfig } from '@modern-js/server-utils';
4
5
  import { SHARED_DIR, SERVER_DIR } from '@modern-js/utils';
5
6
  const TS_CONFIG_FILENAME = 'tsconfig.json';
6
- const FILE_EXTENSIONS = ['.js', '.ts', '.mjs', '.ejs']; // interface Pattern {
7
- // from: string;
8
- // to: string;
9
- // tsconfigPath?: string;
10
- // }
11
- // interface CompileOptions {
12
- // patterns: Pattern[];
13
- // }
14
- // const compile = async (
15
- // appDirectory: string,
16
- // modernConfig: NormalizedConfig,
17
- // compileOptions: CompileOptions,
18
- // ) => {
19
- // const { patterns } = compileOptions;
20
- // const results = await Promise.all(
21
- // patterns.map(pattern => {
22
- // const { from, to, tsconfigPath } = pattern;
23
- // const babelConfig = resolveBabelConfig(appDirectory, modernConfig, {
24
- // tsconfigPath: tsconfigPath ? tsconfigPath : '',
25
- // syntax: 'es6+',
26
- // type: 'commonjs',
27
- // });
28
- // return compiler(
29
- // {
30
- // rootDir: appDirectory,
31
- // distDir: to,
32
- // sourceDir: from,
33
- // extensions: FILE_EXTENSIONS,
34
- // },
35
- // babelConfig,
36
- // );
37
- // }),
38
- // );
39
- // results.forEach(result => {
40
- // if (result.code === 1) {
41
- // throw new Error(result.message);
42
- // }
43
- // });
44
- // };
7
+ const FILE_EXTENSIONS = ['.js', '.ts', '.mjs', '.ejs'];
8
+
9
+ const compile = async (appDirectory, modernConfig, compileOptions) => {
10
+ const {
11
+ patterns
12
+ } = compileOptions;
13
+ const results = await Promise.all(patterns.map(pattern => {
14
+ const {
15
+ from,
16
+ to,
17
+ tsconfigPath
18
+ } = pattern;
19
+ const babelConfig = resolveBabelConfig(appDirectory, modernConfig, {
20
+ tsconfigPath: tsconfigPath ? tsconfigPath : '',
21
+ syntax: 'es6+',
22
+ type: 'commonjs'
23
+ });
24
+ return compiler({
25
+ rootDir: appDirectory,
26
+ distDir: to,
27
+ sourceDir: from,
28
+ extensions: FILE_EXTENSIONS
29
+ }, babelConfig);
30
+ }));
31
+ results.forEach(result => {
32
+ if (result.code === 1) {
33
+ throw new Error(result.message);
34
+ }
35
+ });
36
+ };
45
37
 
46
38
  export default (() => ({
47
39
  name: '@modern-js/plugin-server',
@@ -9,6 +9,8 @@ var _fs = _interopRequireDefault(require("fs"));
9
9
 
10
10
  var _path = _interopRequireDefault(require("path"));
11
11
 
12
+ var _babelCompiler = require("@modern-js/babel-compiler");
13
+
12
14
  var _serverUtils = require("@modern-js/server-utils");
13
15
 
14
16
  var _utils = require("@modern-js/utils");
@@ -16,45 +18,36 @@ var _utils = require("@modern-js/utils");
16
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
19
 
18
20
  const TS_CONFIG_FILENAME = 'tsconfig.json';
19
- const FILE_EXTENSIONS = ['.js', '.ts', '.mjs', '.ejs']; // interface Pattern {
20
- // from: string;
21
- // to: string;
22
- // tsconfigPath?: string;
23
- // }
24
- // interface CompileOptions {
25
- // patterns: Pattern[];
26
- // }
27
- // const compile = async (
28
- // appDirectory: string,
29
- // modernConfig: NormalizedConfig,
30
- // compileOptions: CompileOptions,
31
- // ) => {
32
- // const { patterns } = compileOptions;
33
- // const results = await Promise.all(
34
- // patterns.map(pattern => {
35
- // const { from, to, tsconfigPath } = pattern;
36
- // const babelConfig = resolveBabelConfig(appDirectory, modernConfig, {
37
- // tsconfigPath: tsconfigPath ? tsconfigPath : '',
38
- // syntax: 'es6+',
39
- // type: 'commonjs',
40
- // });
41
- // return compiler(
42
- // {
43
- // rootDir: appDirectory,
44
- // distDir: to,
45
- // sourceDir: from,
46
- // extensions: FILE_EXTENSIONS,
47
- // },
48
- // babelConfig,
49
- // );
50
- // }),
51
- // );
52
- // results.forEach(result => {
53
- // if (result.code === 1) {
54
- // throw new Error(result.message);
55
- // }
56
- // });
57
- // };
21
+ const FILE_EXTENSIONS = ['.js', '.ts', '.mjs', '.ejs'];
22
+
23
+ const compile = async (appDirectory, modernConfig, compileOptions) => {
24
+ const {
25
+ patterns
26
+ } = compileOptions;
27
+ const results = await Promise.all(patterns.map(pattern => {
28
+ const {
29
+ from,
30
+ to,
31
+ tsconfigPath
32
+ } = pattern;
33
+ const babelConfig = (0, _serverUtils.resolveBabelConfig)(appDirectory, modernConfig, {
34
+ tsconfigPath: tsconfigPath ? tsconfigPath : '',
35
+ syntax: 'es6+',
36
+ type: 'commonjs'
37
+ });
38
+ return (0, _babelCompiler.compiler)({
39
+ rootDir: appDirectory,
40
+ distDir: to,
41
+ sourceDir: from,
42
+ extensions: FILE_EXTENSIONS
43
+ }, babelConfig);
44
+ }));
45
+ results.forEach(result => {
46
+ if (result.code === 1) {
47
+ throw new Error(result.message);
48
+ }
49
+ });
50
+ };
58
51
 
59
52
  var _default = () => ({
60
53
  name: '@modern-js/plugin-server',
@@ -97,7 +90,7 @@ var _default = () => ({
97
90
  }
98
91
 
99
92
  if (patterns.length > 0) {
100
- await (0, _serverUtils.compile)(appDirectory, modernConfig, {
93
+ await compile(appDirectory, modernConfig, {
101
94
  patterns
102
95
  });
103
96
  }
@@ -2,48 +2,58 @@ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
3
  import fs from 'fs';
4
4
  import path from 'path';
5
- import { compile } from '@modern-js/server-utils';
5
+ import { compiler } from '@modern-js/babel-compiler';
6
+ import { resolveBabelConfig } from '@modern-js/server-utils';
6
7
  import { SHARED_DIR, SERVER_DIR } from '@modern-js/utils';
7
8
  var TS_CONFIG_FILENAME = 'tsconfig.json';
8
- var FILE_EXTENSIONS = ['.js', '.ts', '.mjs', '.ejs']; // interface Pattern {
9
- // from: string;
10
- // to: string;
11
- // tsconfigPath?: string;
12
- // }
13
- // interface CompileOptions {
14
- // patterns: Pattern[];
15
- // }
16
- // const compile = async (
17
- // appDirectory: string,
18
- // modernConfig: NormalizedConfig,
19
- // compileOptions: CompileOptions,
20
- // ) => {
21
- // const { patterns } = compileOptions;
22
- // const results = await Promise.all(
23
- // patterns.map(pattern => {
24
- // const { from, to, tsconfigPath } = pattern;
25
- // const babelConfig = resolveBabelConfig(appDirectory, modernConfig, {
26
- // tsconfigPath: tsconfigPath ? tsconfigPath : '',
27
- // syntax: 'es6+',
28
- // type: 'commonjs',
29
- // });
30
- // return compiler(
31
- // {
32
- // rootDir: appDirectory,
33
- // distDir: to,
34
- // sourceDir: from,
35
- // extensions: FILE_EXTENSIONS,
36
- // },
37
- // babelConfig,
38
- // );
39
- // }),
40
- // );
41
- // results.forEach(result => {
42
- // if (result.code === 1) {
43
- // throw new Error(result.message);
44
- // }
45
- // });
46
- // };
9
+ var FILE_EXTENSIONS = ['.js', '.ts', '.mjs', '.ejs'];
10
+
11
+ var compile = /*#__PURE__*/function () {
12
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(appDirectory, modernConfig, compileOptions) {
13
+ var patterns, results;
14
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
15
+ while (1) {
16
+ switch (_context.prev = _context.next) {
17
+ case 0:
18
+ patterns = compileOptions.patterns;
19
+ _context.next = 3;
20
+ return Promise.all(patterns.map(function (pattern) {
21
+ var from = pattern.from,
22
+ to = pattern.to,
23
+ tsconfigPath = pattern.tsconfigPath;
24
+ var babelConfig = resolveBabelConfig(appDirectory, modernConfig, {
25
+ tsconfigPath: tsconfigPath ? tsconfigPath : '',
26
+ syntax: 'es6+',
27
+ type: 'commonjs'
28
+ });
29
+ return compiler({
30
+ rootDir: appDirectory,
31
+ distDir: to,
32
+ sourceDir: from,
33
+ extensions: FILE_EXTENSIONS
34
+ }, babelConfig);
35
+ }));
36
+
37
+ case 3:
38
+ results = _context.sent;
39
+ results.forEach(function (result) {
40
+ if (result.code === 1) {
41
+ throw new Error(result.message);
42
+ }
43
+ });
44
+
45
+ case 5:
46
+ case "end":
47
+ return _context.stop();
48
+ }
49
+ }
50
+ }, _callee);
51
+ }));
52
+
53
+ return function compile(_x, _x2, _x3) {
54
+ return _ref.apply(this, arguments);
55
+ };
56
+ }();
47
57
 
48
58
  export default (function () {
49
59
  return {
@@ -54,12 +64,12 @@ export default (function () {
54
64
  return {};
55
65
  },
56
66
  afterBuild: function afterBuild() {
57
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
67
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
58
68
  var _api$useAppContext, appDirectory, distDirectory, modernConfig, distDir, serverDir, sharedDir, tsconfigPath, patterns;
59
69
 
60
- return _regeneratorRuntime().wrap(function _callee$(_context) {
70
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
61
71
  while (1) {
62
- switch (_context.prev = _context.next) {
72
+ switch (_context2.prev = _context2.next) {
63
73
  case 0:
64
74
  _api$useAppContext = api.useAppContext(), appDirectory = _api$useAppContext.appDirectory, distDirectory = _api$useAppContext.distDirectory;
65
75
  modernConfig = api.useResolvedConfigContext();
@@ -86,21 +96,21 @@ export default (function () {
86
96
  }
87
97
 
88
98
  if (!(patterns.length > 0)) {
89
- _context.next = 12;
99
+ _context2.next = 12;
90
100
  break;
91
101
  }
92
102
 
93
- _context.next = 12;
103
+ _context2.next = 12;
94
104
  return compile(appDirectory, modernConfig, {
95
105
  patterns: patterns
96
106
  });
97
107
 
98
108
  case 12:
99
109
  case "end":
100
- return _context.stop();
110
+ return _context2.stop();
101
111
  }
102
112
  }
103
- }, _callee);
113
+ }, _callee2);
104
114
  }))();
105
115
  }
106
116
  };
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.15.1-beta.0",
14
+ "version": "1.17.0",
15
15
  "types": "./dist/types/server.d.ts",
16
16
  "jsnext:source": "./src/server.ts",
17
17
  "main": "./dist/js/node/server.js",
@@ -48,20 +48,20 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@babel/runtime": "^7.18.0",
51
- "@modern-js/babel-compiler": "1.15.0",
52
- "@modern-js/server-utils": "1.15.1-beta.0",
53
- "@modern-js/utils": "1.15.0"
51
+ "@modern-js/babel-compiler": "1.17.0",
52
+ "@modern-js/server-utils": "1.17.0",
53
+ "@modern-js/utils": "1.17.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@modern-js/server-core": "1.15.0",
57
- "@modern-js/core": "1.15.0",
58
- "@scripts/build": "1.15.0",
59
- "@modern-js/types": "1.15.0",
56
+ "@modern-js/server-core": "1.17.0",
57
+ "@modern-js/core": "1.17.0",
58
+ "@scripts/build": "1.17.0",
59
+ "@modern-js/types": "1.17.0",
60
60
  "typescript": "^4",
61
61
  "@types/jest": "^27",
62
62
  "@types/node": "^14",
63
63
  "jest": "^27",
64
- "@scripts/jest-config": "1.15.0"
64
+ "@scripts/jest-config": "1.17.0"
65
65
  },
66
66
  "sideEffects": [
67
67
  "*.css",
@@ -71,8 +71,7 @@
71
71
  ],
72
72
  "publishConfig": {
73
73
  "access": "public",
74
- "registry": "https://registry.npmjs.org/",
75
- "types": "./dist/types/server.d.ts"
74
+ "registry": "https://registry.npmjs.org/"
76
75
  },
77
76
  "wireit": {
78
77
  "build": {