@modern-js/core 1.0.0-rc.5 → 1.0.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 +274 -0
- package/README.md +21 -20
- package/dist/js/modern/config/defaults.js +2 -1
- package/dist/js/modern/config/index.js +1 -1
- package/dist/js/modern/config/schema/deploy.js +1 -15
- package/dist/js/modern/config/schema/index.js +3 -0
- package/dist/js/modern/config/schema/server.js +3 -0
- package/dist/js/modern/context.js +4 -4
- package/dist/js/modern/index.js +17 -13
- package/dist/js/modern/initWatcher.js +2 -8
- package/dist/js/modern/loadEnv.js +1 -1
- package/dist/js/modern/loadPlugins.js +3 -3
- package/dist/js/node/config/defaults.js +2 -1
- package/dist/js/node/config/index.js +1 -1
- package/dist/js/node/config/schema/deploy.js +1 -15
- package/dist/js/node/config/schema/index.js +3 -0
- package/dist/js/node/config/schema/server.js +3 -0
- package/dist/js/node/context.js +9 -9
- package/dist/js/node/index.js +54 -23
- package/dist/js/node/initWatcher.js +5 -12
- package/dist/js/node/loadEnv.js +3 -3
- package/dist/js/node/loadPlugins.js +2 -2
- package/dist/types/config/defaults.d.ts +1 -0
- package/dist/types/config/index.d.ts +3 -3
- package/dist/types/config/schema/deploy.d.ts +1 -15
- package/dist/types/config/schema/index.d.ts +7 -15
- package/dist/types/config/schema/server.d.ts +3 -0
- package/dist/types/context.d.ts +3 -9
- package/dist/types/index.d.ts +5 -3
- package/dist/types/initWatcher.d.ts +1 -2
- package/package.json +19 -8
- package/src/config/defaults.ts +1 -1
- package/src/config/index.ts +4 -4
- package/src/config/schema/deploy.ts +1 -7
- package/src/config/schema/index.ts +6 -1
- package/src/config/schema/server.ts +1 -0
- package/src/context.ts +4 -4
- package/src/index.ts +30 -22
- package/src/initWatcher.ts +2 -6
- package/src/loadEnv.ts +1 -1
- package/src/loadPlugins.ts +2 -1
- package/tests/loadEnv.test.ts +1 -1
- package/tests/loadPlugin.test.ts +1 -1
package/src/initWatcher.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
1
|
import crypto from 'crypto';
|
|
3
2
|
import fs from 'fs';
|
|
3
|
+
import { path, isDev, createDebugger } from '@modern-js/utils';
|
|
4
4
|
import chokidar from 'chokidar';
|
|
5
|
-
import { isDev, createDebugger } from '@modern-js/utils';
|
|
6
5
|
import { NormalizedConfig } from './config/mergeConfig';
|
|
7
6
|
import { LoadedConfig } from './config';
|
|
8
7
|
import { HooksRunner } from '.';
|
|
@@ -17,15 +16,12 @@ const hashMap = new Map<string, string>();
|
|
|
17
16
|
export const initWatcher = async (
|
|
18
17
|
loaded: LoadedConfig,
|
|
19
18
|
appDirectory: string,
|
|
20
|
-
|
|
19
|
+
configDir: string | undefined,
|
|
21
20
|
hooksRunner: HooksRunner,
|
|
22
21
|
argv: string[],
|
|
23
22
|
) => {
|
|
24
23
|
// only add fs watcher on dev mode.
|
|
25
24
|
if (isDev() && argv[0] === 'dev') {
|
|
26
|
-
const {
|
|
27
|
-
source: { configDir },
|
|
28
|
-
} = resovledConfig;
|
|
29
25
|
|
|
30
26
|
const extraFiles = await hooksRunner.watchFiles();
|
|
31
27
|
|
package/src/loadEnv.ts
CHANGED
package/src/loadPlugins.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
createDebugger,
|
|
4
4
|
compatRequire,
|
|
5
5
|
INTERNAL_PLUGINS,
|
|
6
|
+
upath
|
|
6
7
|
} from '@modern-js/utils';
|
|
7
8
|
|
|
8
9
|
const debug = createDebugger('load-plugins');
|
|
@@ -24,7 +25,7 @@ const resolvePlugin = (appDirectory: string, plugin: PluginConfigItem) => {
|
|
|
24
25
|
const tryResolve = (name: string) => {
|
|
25
26
|
let filePath = '';
|
|
26
27
|
try {
|
|
27
|
-
filePath = require.resolve(name, { paths: [appDirectory] });
|
|
28
|
+
filePath = upath.normalizeSafe(require.resolve(name, { paths: [appDirectory] }));
|
|
28
29
|
delete require.cache[filePath];
|
|
29
30
|
} catch (err) {
|
|
30
31
|
if ((err as any).code === 'MODULE_NOT_FOUND') {
|
package/tests/loadEnv.test.ts
CHANGED
package/tests/loadPlugin.test.ts
CHANGED