@modern-js/plugin-server-build 0.0.0-canary-20220121065829 → 0.0.0-canary-20220307090601

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,6 +1,30 @@
1
1
  # @modern-js/plugin-server-build
2
2
 
3
- ## 0.0.0-canary-20220121065829
3
+ ## 0.0.0-canary-20220307090601
4
+
5
+ ### Patch Changes
6
+
7
+ - 55e18278: chore: remove unused dependencies and devDependencies
8
+ - Updated dependencies [55e18278]
9
+ - Updated dependencies [a7f42f48]
10
+ - @modern-js/core@0.0.0-canary-20220307090601
11
+ - @modern-js/babel-compiler@0.0.0-canary-20220307090601
12
+ - @modern-js/utils@0.0.0-canary-20220307090601
13
+
14
+ ## 1.2.1
15
+
16
+ ### Patch Changes
17
+
18
+ - 83166714: change .npmignore
19
+ - Updated dependencies [83166714]
20
+ - Updated dependencies [c3de9882]
21
+ - Updated dependencies [33ff48af]
22
+ - @modern-js/core@1.3.2
23
+ - @modern-js/server-utils@1.2.1
24
+ - @modern-js/babel-compiler@1.2.1
25
+ - @modern-js/utils@1.2.2
26
+
27
+ ## 1.2.0
4
28
 
5
29
  ### Minor Changes
6
30
 
@@ -15,10 +39,11 @@
15
39
  - Updated dependencies [cfe11628]
16
40
  - Updated dependencies [146dcd85]
17
41
  - Updated dependencies [146dcd85]
18
- - @modern-js/utils@0.0.0-canary-20220121065829
19
- - @modern-js/core@0.0.0-canary-20220121065829
20
- - @modern-js/server-utils@0.0.0-canary-20220121065829
21
- - @modern-js/babel-compiler@0.0.0-canary-20220121065829
42
+ - Updated dependencies [1ebc7ee2]
43
+ - @modern-js/utils@1.2.0
44
+ - @modern-js/core@1.3.0
45
+ - @modern-js/server-utils@1.2.0
46
+ - @modern-js/babel-compiler@1.2.0
22
47
 
23
48
  ## 1.1.1
24
49
 
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "0.0.0-canary-20220121065829",
14
+ "version": "0.0.0-canary-20220307090601",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -29,26 +29,24 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@babel/runtime": "^7",
32
- "@modern-js/babel-compiler": "^0.0.0-canary-20220121065829",
33
- "@modern-js/server-utils": "^0.0.0-canary-20220121065829",
34
- "@modern-js/utils": "^0.0.0-canary-20220121065829",
35
- "globby": "^12.0.2",
36
- "json5": "^2.2.0"
32
+ "@modern-js/babel-compiler": "^0.0.0-canary-20220307090601",
33
+ "@modern-js/server-utils": "^1.2.1",
34
+ "@modern-js/utils": "^0.0.0-canary-20220307090601"
37
35
  },
38
36
  "devDependencies": {
39
- "@modern-js/plugin-analyze": "^0.0.0-canary-20220121065829",
37
+ "@modern-js/plugin-analyze": "^1.2.1",
40
38
  "@types/babel__core": "^7.1.15",
41
39
  "@types/jest": "^26",
42
40
  "@types/node": "^14",
43
41
  "ts-jest": "^27.0.5",
44
42
  "typescript": "^4",
45
- "@modern-js/core": "^0.0.0-canary-20220121065829",
43
+ "@modern-js/core": "^0.0.0-canary-20220307090601",
46
44
  "@scripts/build": "0.0.0",
47
45
  "jest": "^27",
48
46
  "@scripts/jest-config": "0.0.0"
49
47
  },
50
48
  "peerDependencies": {
51
- "@modern-js/core": "^0.0.0-canary-20220121065829"
49
+ "@modern-js/core": "^0.0.0-canary-20220307090601"
52
50
  },
53
51
  "sideEffects": false,
54
52
  "modernConfig": {
@@ -58,8 +56,7 @@
58
56
  },
59
57
  "publishConfig": {
60
58
  "registry": "https://registry.npmjs.org/",
61
- "access": "public",
62
- "types": "./dist/types/index.d.ts"
59
+ "access": "public"
63
60
  },
64
61
  "scripts": {
65
62
  "new": "modern new",
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "@modern-js/tsconfig/base",
3
+ "compilerOptions": {
4
+ "declaration": true,
5
+ "jsx": "preserve",
6
+ "baseUrl": "./",
7
+ "outDir": "./out",
8
+ "emitDeclarationOnly": true,
9
+ "isolatedModules": true,
10
+ "paths": {},
11
+ "types": ["node", "jest"]
12
+ }
13
+ }
package/src/index.ts DELETED
@@ -1,98 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import {
4
- createPlugin,
5
- useAppContext,
6
- useResolvedConfigContext,
7
- NormalizedConfig,
8
- } from '@modern-js/core';
9
- import { compiler } from '@modern-js/babel-compiler';
10
- import { resolveBabelConfig } from '@modern-js/server-utils';
11
-
12
- const SERVER_DIR = './server';
13
- const SHARED_DIR = './shared';
14
- const TS_CONFIG_FILENAME = 'tsconfig.json';
15
- const FILE_EXTENSIONS = ['.js', '.ts', '.mjs', '.ejs'];
16
-
17
- interface Pattern {
18
- from: string;
19
- to: string;
20
- tsconfigPath?: string;
21
- }
22
-
23
- interface CompileOptions {
24
- patterns: Pattern[];
25
- }
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
- };
58
-
59
- export default createPlugin(
60
- () => ({
61
- config() {
62
- return {};
63
- },
64
- async afterBuild() {
65
- // eslint-disable-next-line react-hooks/rules-of-hooks
66
- const { appDirectory, distDirectory } = useAppContext();
67
- // eslint-disable-next-line react-hooks/rules-of-hooks
68
- const modernConfig = useResolvedConfigContext();
69
-
70
- const distDir = path.resolve(distDirectory);
71
- const serverDir = path.resolve(appDirectory, SERVER_DIR);
72
- const sharedDir = path.resolve(appDirectory, SHARED_DIR);
73
- const tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
74
-
75
- const patterns = [];
76
- if (fs.existsSync(serverDir)) {
77
- patterns.push({
78
- from: serverDir,
79
- to: distDir,
80
- tsconfigPath,
81
- });
82
- }
83
-
84
- if (fs.existsSync(sharedDir)) {
85
- patterns.push({
86
- from: sharedDir,
87
- to: distDir,
88
- tsconfigPath,
89
- });
90
- }
91
-
92
- if (patterns.length > 0) {
93
- await compile(appDirectory, modernConfig, { patterns });
94
- }
95
- },
96
- }),
97
- { name: '@modern-js/plugin-server-build' },
98
- ) as any;