@modern-js/plugin-server-build 1.2.2 → 1.2.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,14 @@
1
1
  # @modern-js/plugin-server-build
2
2
 
3
+ ## 1.2.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 61e3f623: feat: convert to new plugin
8
+ - 681a1ff9: feat: remove unnecessary peerDependencies
9
+ - Updated dependencies [c2046f37]
10
+ - @modern-js/utils@1.3.6
11
+
3
12
  ## 1.2.2
4
13
 
5
14
  ### Patch Changes
@@ -1,6 +1,5 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
- import { createPlugin, useAppContext, useResolvedConfigContext } from '@modern-js/core';
4
3
  import { compiler } from '@modern-js/babel-compiler';
5
4
  import { resolveBabelConfig } from '@modern-js/server-utils';
6
5
  const SERVER_DIR = './server';
@@ -37,48 +36,43 @@ const compile = async (appDirectory, modernConfig, compileOptions) => {
37
36
  });
38
37
  };
39
38
 
40
- export default createPlugin(() => ({
41
- config() {
42
- return {};
43
- },
39
+ export default (() => ({
40
+ name: '@modern-js/plugin-server-build',
41
+ setup: api => ({
42
+ async afterBuild() {
43
+ const {
44
+ appDirectory,
45
+ distDirectory
46
+ } = api.useAppContext();
47
+ const modernConfig = api.useResolvedConfigContext();
48
+ const distDir = path.resolve(distDirectory);
49
+ const serverDir = path.resolve(appDirectory, SERVER_DIR);
50
+ const sharedDir = path.resolve(appDirectory, SHARED_DIR);
51
+ const tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
52
+ const patterns = [];
44
53
 
45
- async afterBuild() {
46
- // eslint-disable-next-line react-hooks/rules-of-hooks
47
- const {
48
- appDirectory,
49
- distDirectory
50
- } = useAppContext(); // eslint-disable-next-line react-hooks/rules-of-hooks
51
-
52
- const modernConfig = useResolvedConfigContext();
53
- const distDir = path.resolve(distDirectory);
54
- const serverDir = path.resolve(appDirectory, SERVER_DIR);
55
- const sharedDir = path.resolve(appDirectory, SHARED_DIR);
56
- const tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
57
- const patterns = [];
54
+ if (fs.existsSync(serverDir)) {
55
+ patterns.push({
56
+ from: serverDir,
57
+ to: distDir,
58
+ tsconfigPath
59
+ });
60
+ }
58
61
 
59
- if (fs.existsSync(serverDir)) {
60
- patterns.push({
61
- from: serverDir,
62
- to: distDir,
63
- tsconfigPath
64
- });
65
- }
66
-
67
- if (fs.existsSync(sharedDir)) {
68
- patterns.push({
69
- from: sharedDir,
70
- to: distDir,
71
- tsconfigPath
72
- });
73
- }
62
+ if (fs.existsSync(sharedDir)) {
63
+ patterns.push({
64
+ from: sharedDir,
65
+ to: distDir,
66
+ tsconfigPath
67
+ });
68
+ }
74
69
 
75
- if (patterns.length > 0) {
76
- await compile(appDirectory, modernConfig, {
77
- patterns
78
- });
70
+ if (patterns.length > 0) {
71
+ await compile(appDirectory, modernConfig, {
72
+ patterns
73
+ });
74
+ }
79
75
  }
80
- }
81
76
 
82
- }), {
83
- name: '@modern-js/plugin-server-build'
84
- });
77
+ })
78
+ }));
@@ -9,8 +9,6 @@ var _fs = _interopRequireDefault(require("fs"));
9
9
 
10
10
  var _path = _interopRequireDefault(require("path"));
11
11
 
12
- var _core = require("@modern-js/core");
13
-
14
12
  var _babelCompiler = require("@modern-js/babel-compiler");
15
13
 
16
14
  var _serverUtils = require("@modern-js/server-utils");
@@ -51,55 +49,50 @@ const compile = async (appDirectory, modernConfig, compileOptions) => {
51
49
  });
52
50
  };
53
51
 
54
- var _default = (0, _core.createPlugin)(() => ({
55
- config() {
56
- return {};
57
- },
58
-
59
- async afterBuild() {
60
- // eslint-disable-next-line react-hooks/rules-of-hooks
61
- const {
62
- appDirectory,
63
- distDirectory
64
- } = (0, _core.useAppContext)(); // eslint-disable-next-line react-hooks/rules-of-hooks
65
-
66
- const modernConfig = (0, _core.useResolvedConfigContext)();
67
-
68
- const distDir = _path.default.resolve(distDirectory);
69
-
70
- const serverDir = _path.default.resolve(appDirectory, SERVER_DIR);
71
-
72
- const sharedDir = _path.default.resolve(appDirectory, SHARED_DIR);
73
-
74
- const tsconfigPath = _path.default.resolve(appDirectory, TS_CONFIG_FILENAME);
75
-
76
- const patterns = [];
77
-
78
- if (_fs.default.existsSync(serverDir)) {
79
- patterns.push({
80
- from: serverDir,
81
- to: distDir,
82
- tsconfigPath
83
- });
84
- }
85
-
86
- if (_fs.default.existsSync(sharedDir)) {
87
- patterns.push({
88
- from: sharedDir,
89
- to: distDir,
90
- tsconfigPath
91
- });
92
- }
93
-
94
- if (patterns.length > 0) {
95
- await compile(appDirectory, modernConfig, {
96
- patterns
97
- });
52
+ var _default = () => ({
53
+ name: '@modern-js/plugin-server-build',
54
+ setup: api => ({
55
+ async afterBuild() {
56
+ const {
57
+ appDirectory,
58
+ distDirectory
59
+ } = api.useAppContext();
60
+ const modernConfig = api.useResolvedConfigContext();
61
+
62
+ const distDir = _path.default.resolve(distDirectory);
63
+
64
+ const serverDir = _path.default.resolve(appDirectory, SERVER_DIR);
65
+
66
+ const sharedDir = _path.default.resolve(appDirectory, SHARED_DIR);
67
+
68
+ const tsconfigPath = _path.default.resolve(appDirectory, TS_CONFIG_FILENAME);
69
+
70
+ const patterns = [];
71
+
72
+ if (_fs.default.existsSync(serverDir)) {
73
+ patterns.push({
74
+ from: serverDir,
75
+ to: distDir,
76
+ tsconfigPath
77
+ });
78
+ }
79
+
80
+ if (_fs.default.existsSync(sharedDir)) {
81
+ patterns.push({
82
+ from: sharedDir,
83
+ to: distDir,
84
+ tsconfigPath
85
+ });
86
+ }
87
+
88
+ if (patterns.length > 0) {
89
+ await compile(appDirectory, modernConfig, {
90
+ patterns
91
+ });
92
+ }
98
93
  }
99
- }
100
94
 
101
- }), {
102
- name: '@modern-js/plugin-server-build'
95
+ })
103
96
  });
104
97
 
105
98
  exports.default = _default;
@@ -1,3 +1,5 @@
1
- declare const _default: any;
1
+ import type { CliPlugin } from '@modern-js/core';
2
+
3
+ declare const _default: () => CliPlugin;
2
4
 
3
5
  export default _default;
package/jest.config.js CHANGED
@@ -2,7 +2,6 @@ const sharedConfig = require('@scripts/jest-config');
2
2
 
3
3
  /** @type {import('@jest/types').Config.InitialOptions} */
4
4
  module.exports = {
5
- // eslint-disable-next-line node/no-unsupported-features/es-syntax
6
5
  ...sharedConfig,
7
6
  rootDir: __dirname,
8
7
  };
package/modern.config.js CHANGED
@@ -1,2 +1,6 @@
1
1
  /** @type {import('@modern-js/module-tools').UserConfig} */
2
- module.exports = {};
2
+ module.exports = {
3
+ output: {
4
+ packageMode: 'node-js',
5
+ },
6
+ };
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.3",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -31,29 +31,21 @@
31
31
  "@babel/runtime": "^7",
32
32
  "@modern-js/babel-compiler": "^1.2.2",
33
33
  "@modern-js/server-utils": "^1.2.1",
34
- "@modern-js/utils": "^1.3.3"
34
+ "@modern-js/utils": "^1.3.6"
35
35
  },
36
36
  "devDependencies": {
37
- "@modern-js/plugin-analyze": "^1.2.1",
37
+ "@modern-js/plugin-analyze": "^1.3.4",
38
38
  "@types/babel__core": "^7.1.15",
39
39
  "@types/jest": "^26",
40
40
  "@types/node": "^14",
41
41
  "ts-jest": "^27.0.5",
42
42
  "typescript": "^4",
43
- "@modern-js/core": "^1.4.4",
43
+ "@modern-js/core": "^1.6.0",
44
44
  "@scripts/build": "0.0.0",
45
45
  "jest": "^27",
46
46
  "@scripts/jest-config": "0.0.0"
47
47
  },
48
- "peerDependencies": {
49
- "@modern-js/core": "^1.4.4"
50
- },
51
48
  "sideEffects": false,
52
- "modernConfig": {
53
- "output": {
54
- "packageMode": "node-js"
55
- }
56
- },
57
49
  "publishConfig": {
58
50
  "registry": "https://registry.npmjs.org/",
59
51
  "access": "public"
package/tsconfig.json CHANGED
@@ -10,5 +10,5 @@
10
10
  "paths": {},
11
11
  "types": ["node", "jest"]
12
12
  },
13
- "include": ["src", "src/.ts"]
13
+ "include": ["src"]
14
14
  }