@modern-js/plugin-server-build 1.1.2-rc.0 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,20 +1,55 @@
1
1
  # @modern-js/plugin-server-build
2
2
 
3
- ## 1.1.2-rc.0
3
+ ## 1.2.2
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - Updated dependencies [d927bc83]
8
- - Updated dependencies [d73ff455]
9
- - Updated dependencies [9c1ab865]
10
- - Updated dependencies [d73ff455]
11
- - Updated dependencies [d73ff455]
12
- - Updated dependencies [d73ff455]
13
- - Updated dependencies [d73ff455]
14
- - @modern-js/utils@1.1.4-rc.0
15
- - @modern-js/core@1.1.4-rc.0
16
- - @modern-js/server-utils@1.1.3-rc.0
17
- - @modern-js/babel-compiler@1.1.3-rc.0
7
+ - 55e18278: chore: remove unused dependencies and devDependencies
8
+ - Updated dependencies [969f172f]
9
+ - Updated dependencies [4c792f68]
10
+ - Updated dependencies [4b5d4bf4]
11
+ - Updated dependencies [62f5b8c8]
12
+ - Updated dependencies [55e18278]
13
+ - Updated dependencies [4499a674]
14
+ - Updated dependencies [403f5169]
15
+ - Updated dependencies [a7f42f48]
16
+ - @modern-js/core@1.4.4
17
+ - @modern-js/utils@1.3.3
18
+ - @modern-js/babel-compiler@1.2.2
19
+
20
+ ## 1.2.1
21
+
22
+ ### Patch Changes
23
+
24
+ - 83166714: change .npmignore
25
+ - Updated dependencies [83166714]
26
+ - Updated dependencies [c3de9882]
27
+ - Updated dependencies [33ff48af]
28
+ - @modern-js/core@1.3.2
29
+ - @modern-js/server-utils@1.2.1
30
+ - @modern-js/babel-compiler@1.2.1
31
+ - @modern-js/utils@1.2.2
32
+
33
+ ## 1.2.0
34
+
35
+ ### Minor Changes
36
+
37
+ - cfe11628: Make Modern.js self bootstraping
38
+
39
+ ### Patch Changes
40
+
41
+ - Updated dependencies [2da09c69]
42
+ - Updated dependencies [fc71e36f]
43
+ - Updated dependencies [146dcd85]
44
+ - Updated dependencies [c3d46ee4]
45
+ - Updated dependencies [cfe11628]
46
+ - Updated dependencies [146dcd85]
47
+ - Updated dependencies [146dcd85]
48
+ - Updated dependencies [1ebc7ee2]
49
+ - @modern-js/utils@1.2.0
50
+ - @modern-js/core@1.3.0
51
+ - @modern-js/server-utils@1.2.0
52
+ - @modern-js/babel-compiler@1.2.0
18
53
 
19
54
  ## 1.1.1
20
55
 
package/jest.config.js ADDED
@@ -0,0 +1,8 @@
1
+ const sharedConfig = require('@scripts/jest-config');
2
+
3
+ /** @type {import('@jest/types').Config.InitialOptions} */
4
+ module.exports = {
5
+ // eslint-disable-next-line node/no-unsupported-features/es-syntax
6
+ ...sharedConfig,
7
+ rootDir: __dirname,
8
+ };
package/modern.config.js CHANGED
@@ -1,10 +1,2 @@
1
1
  /** @type {import('@modern-js/module-tools').UserConfig} */
2
- module.exports = {
3
- testing: {
4
- jest: {
5
- collectCoverage: true,
6
- collectCoverageFrom: ['src/**/*.ts'],
7
- coveragePathIgnorePatterns: ['/node_modules/'],
8
- },
9
- },
10
- };
2
+ module.exports = {};
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.1.2-rc.0",
14
+ "version": "1.2.2",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -20,6 +20,7 @@
20
20
  "exports": {
21
21
  ".": {
22
22
  "node": {
23
+ "jsnext:source": "./src/index.ts",
23
24
  "import": "./dist/js/modern/index.js",
24
25
  "require": "./dist/js/node/index.js"
25
26
  },
@@ -28,25 +29,24 @@
28
29
  },
29
30
  "dependencies": {
30
31
  "@babel/runtime": "^7",
31
- "@modern-js/babel-compiler": "^1.1.3-rc.0",
32
- "@modern-js/server-utils": "^1.1.3-rc.0",
33
- "@modern-js/utils": "^1.1.4-rc.0",
34
- "globby": "^12.0.2",
35
- "json5": "^2.2.0"
32
+ "@modern-js/babel-compiler": "^1.2.2",
33
+ "@modern-js/server-utils": "^1.2.1",
34
+ "@modern-js/utils": "^1.3.3"
36
35
  },
37
36
  "devDependencies": {
38
- "@modern-js/plugin-analyze": "^1.1.2-rc.0",
37
+ "@modern-js/plugin-analyze": "^1.2.1",
39
38
  "@types/babel__core": "^7.1.15",
40
39
  "@types/jest": "^26",
41
40
  "@types/node": "^14",
42
41
  "ts-jest": "^27.0.5",
43
42
  "typescript": "^4",
44
- "@modern-js/core": "^1.1.4-rc.0",
45
- "@modern-js/plugin-testing": "^1.1.1",
46
- "@modern-js/module-tools": "^1.1.1"
43
+ "@modern-js/core": "^1.4.4",
44
+ "@scripts/build": "0.0.0",
45
+ "jest": "^27",
46
+ "@scripts/jest-config": "0.0.0"
47
47
  },
48
48
  "peerDependencies": {
49
- "@modern-js/core": "^1.1.4-rc.0"
49
+ "@modern-js/core": "^1.4.4"
50
50
  },
51
51
  "sideEffects": false,
52
52
  "modernConfig": {
@@ -62,7 +62,7 @@
62
62
  "new": "modern new",
63
63
  "build": "modern build",
64
64
  "dev": "modern build --watch",
65
- "test": "modern test --passWithNoTests"
65
+ "test": "jest --passWithNoTests"
66
66
  },
67
67
  "readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
68
68
  }
@@ -0,0 +1,7 @@
1
+ import plugin from '../src';
2
+
3
+ describe('plugin-server-build', () => {
4
+ it('default', () => {
5
+ expect(plugin).toBeDefined();
6
+ });
7
+ });
@@ -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/tsconfig.json CHANGED
@@ -7,9 +7,7 @@
7
7
  "skipLibCheck": true,
8
8
  "esModuleInterop": true,
9
9
  "isolatedModules": true,
10
- "paths": {
11
- "@/*": ["./src/*"]
12
- },
10
+ "paths": {},
13
11
  "types": ["node", "jest"]
14
12
  },
15
13
  "include": ["src", "src/.ts"]
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;