@modern-js/core 1.0.0-rc.14 → 1.0.0-rc.18
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 +60 -0
- package/dist/js/modern/config/index.js +1 -1
- package/dist/js/modern/config/schema/server.js +3 -0
- package/dist/js/modern/context.js +1 -1
- package/dist/js/modern/index.js +4 -5
- package/dist/js/modern/initWatcher.js +1 -2
- package/dist/js/modern/loadEnv.js +1 -1
- package/dist/js/modern/loadPlugins.js +3 -3
- package/dist/js/node/config/index.js +1 -1
- package/dist/js/node/config/schema/server.js +3 -0
- package/dist/js/node/context.js +6 -6
- package/dist/js/node/index.js +4 -16
- package/dist/js/node/initWatcher.js +4 -6
- package/dist/js/node/loadEnv.js +3 -3
- package/dist/js/node/loadPlugins.js +2 -2
- package/dist/types/config/index.d.ts +1 -0
- package/dist/types/config/schema/index.d.ts +3 -0
- package/dist/types/config/schema/server.d.ts +3 -0
- package/dist/types/index.d.ts +2 -2
- package/package.json +7 -7
- package/src/config/index.ts +2 -1
- package/src/config/schema/server.ts +1 -0
- package/src/context.ts +1 -1
- package/src/index.ts +10 -10
- package/src/initWatcher.ts +1 -2
- 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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,65 @@
|
|
|
1
1
|
# @modern-js/core
|
|
2
2
|
|
|
3
|
+
## 1.0.0-rc.18
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 224f7fe: fix server route match
|
|
8
|
+
- 30ac27c: feat: add generator package description
|
|
9
|
+
- 204c626: feat: initial
|
|
10
|
+
- 63be0a5: fix: #118 #104
|
|
11
|
+
- Updated dependencies [224f7fe]
|
|
12
|
+
- Updated dependencies [30ac27c]
|
|
13
|
+
- Updated dependencies [204c626]
|
|
14
|
+
- Updated dependencies [63be0a5]
|
|
15
|
+
- @modern-js/load-config@1.0.0-rc.22
|
|
16
|
+
- @modern-js/plugin@1.0.0-rc.18
|
|
17
|
+
- @modern-js/utils@1.0.0-rc.18
|
|
18
|
+
|
|
19
|
+
## 1.0.0-rc.17
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- 224f7fe: fix server route match
|
|
24
|
+
- 30ac27c: feat: add generator package description
|
|
25
|
+
- 204c626: feat: initial
|
|
26
|
+
- fix: #118 #104
|
|
27
|
+
- Updated dependencies [224f7fe]
|
|
28
|
+
- Updated dependencies [30ac27c]
|
|
29
|
+
- Updated dependencies [204c626]
|
|
30
|
+
- Updated dependencies [undefined]
|
|
31
|
+
- @modern-js/load-config@1.0.0-rc.17
|
|
32
|
+
- @modern-js/plugin@1.0.0-rc.17
|
|
33
|
+
- @modern-js/utils@1.0.0-rc.17
|
|
34
|
+
|
|
35
|
+
## 1.0.0-rc.16
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- 224f7fe: fix server route match
|
|
40
|
+
- 30ac27c: feat: add generator package description
|
|
41
|
+
- 204c626: feat: initial
|
|
42
|
+
- Updated dependencies [224f7fe]
|
|
43
|
+
- Updated dependencies [30ac27c]
|
|
44
|
+
- Updated dependencies [204c626]
|
|
45
|
+
- @modern-js/load-config@1.0.0-rc.16
|
|
46
|
+
- @modern-js/plugin@1.0.0-rc.16
|
|
47
|
+
- @modern-js/utils@1.0.0-rc.16
|
|
48
|
+
|
|
49
|
+
## 1.0.0-rc.15
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- 224f7fe: fix server route match
|
|
54
|
+
- 30ac27c: feat: add generator package description
|
|
55
|
+
- 204c626: feat: initial
|
|
56
|
+
- Updated dependencies [224f7fe]
|
|
57
|
+
- Updated dependencies [30ac27c]
|
|
58
|
+
- Updated dependencies [204c626]
|
|
59
|
+
- @modern-js/load-config@1.0.0-rc.15
|
|
60
|
+
- @modern-js/plugin@1.0.0-rc.15
|
|
61
|
+
- @modern-js/utils@1.0.0-rc.15
|
|
62
|
+
|
|
3
63
|
## 1.0.0-rc.14
|
|
4
64
|
|
|
5
65
|
### Patch Changes
|
|
@@ -20,7 +20,7 @@ const debug = createDebugger('resolve-config');
|
|
|
20
20
|
export { defaults as defaultsConfig };
|
|
21
21
|
export const defineConfig = config => config;
|
|
22
22
|
export const loadUserConfig = async (appDirectory, filePath) => {
|
|
23
|
-
const loaded = loadConfig(appDirectory, filePath);
|
|
23
|
+
const loaded = await loadConfig(appDirectory, filePath);
|
|
24
24
|
const config = !loaded ? {} : await (typeof loaded.config === 'function' ? loaded.config(0) : loaded.config);
|
|
25
25
|
return {
|
|
26
26
|
config: mergeWith({}, config || {}, (loaded === null || loaded === void 0 ? void 0 : loaded.pkgConfig) || {}),
|
package/dist/js/modern/index.js
CHANGED
|
@@ -4,10 +4,9 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4
4
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
7
|
-
import path from '
|
|
8
|
-
import { createAsyncManager,
|
|
7
|
+
import { path, upath, compatRequire, pkgUp, ensureAbsolutePath, logger } from '@modern-js/utils';
|
|
8
|
+
import { createAsyncManager, createAsyncWorkflow, createParallelWorkflow } from '@modern-js/plugin';
|
|
9
9
|
import { enable } from '@modern-js/plugin/node';
|
|
10
|
-
import { compatRequire, pkgUp, ensureAbsolutePath, logger } from '@modern-js/utils';
|
|
11
10
|
import { program } from "./utils/commander";
|
|
12
11
|
import { resolveConfig, defineConfig, loadUserConfig } from "./config";
|
|
13
12
|
import { loadPlugins } from "./loadPlugins";
|
|
@@ -35,8 +34,8 @@ export const {
|
|
|
35
34
|
registe: registerHook,
|
|
36
35
|
useRunner: mountHook
|
|
37
36
|
} = manager;
|
|
38
|
-
export const usePlugins = plugins => plugins.forEach(plugin => manager.usePlugin(compatRequire(require.resolve(plugin))));
|
|
39
|
-
export { defineConfig,
|
|
37
|
+
export const usePlugins = plugins => plugins.forEach(plugin => manager.usePlugin(compatRequire(upath.normalize(require.resolve(plugin)))));
|
|
38
|
+
export { defineConfig, AppContext, useAppContext, useConfigContext, useResolvedConfigContext };
|
|
40
39
|
|
|
41
40
|
const initAppDir = async () => {
|
|
42
41
|
const pkg = await pkgUp({
|
|
@@ -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
|
const debug = createDebugger('watch-files');
|
|
7
6
|
|
|
8
7
|
const md5 = data => crypto.createHash('md5').update(data).digest('hex');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isDepExists, createDebugger, compatRequire, INTERNAL_PLUGINS } from '@modern-js/utils';
|
|
1
|
+
import { isDepExists, createDebugger, compatRequire, INTERNAL_PLUGINS, upath } from '@modern-js/utils';
|
|
2
2
|
const debug = createDebugger('load-plugins');
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -12,9 +12,9 @@ const resolvePlugin = (appDirectory, plugin) => {
|
|
|
12
12
|
let filePath = '';
|
|
13
13
|
|
|
14
14
|
try {
|
|
15
|
-
filePath = require.resolve(name, {
|
|
15
|
+
filePath = upath.normalizeSafe(require.resolve(name, {
|
|
16
16
|
paths: [appDirectory]
|
|
17
|
-
});
|
|
17
|
+
}));
|
|
18
18
|
delete require.cache[filePath];
|
|
19
19
|
} catch (err) {
|
|
20
20
|
if (err.code === 'MODULE_NOT_FOUND') {
|
|
@@ -50,7 +50,7 @@ const defineConfig = config => config;
|
|
|
50
50
|
exports.defineConfig = defineConfig;
|
|
51
51
|
|
|
52
52
|
const loadUserConfig = async (appDirectory, filePath) => {
|
|
53
|
-
const loaded = (0, _loadConfig.loadConfig)(appDirectory, filePath);
|
|
53
|
+
const loaded = await (0, _loadConfig.loadConfig)(appDirectory, filePath);
|
|
54
54
|
const config = !loaded ? {} : await (typeof loaded.config === 'function' ? loaded.config(0) : loaded.config);
|
|
55
55
|
return {
|
|
56
56
|
config: (0, _lodash.default)({}, config || {}, (loaded === null || loaded === void 0 ? void 0 : loaded.pkgConfig) || {}),
|
package/dist/js/node/context.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useResolvedConfigContext = exports.useConfigContext = exports.useAppContext = exports.initAppContext = exports.ResolvedConfigContext = exports.ConfigContext = exports.AppContext = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _utils = require("@modern-js/utils");
|
|
9
9
|
|
|
10
10
|
var _plugin = require("@modern-js/plugin");
|
|
11
11
|
|
|
@@ -37,12 +37,12 @@ const initAppContext = (appDirectory, plugins, configFile) => ({
|
|
|
37
37
|
configFile,
|
|
38
38
|
ip: _address.default.ip(),
|
|
39
39
|
port: 0,
|
|
40
|
-
packageName: require(
|
|
41
|
-
srcDirectory:
|
|
40
|
+
packageName: require(_utils.path.resolve(appDirectory, './package.json')).name,
|
|
41
|
+
srcDirectory: _utils.path.resolve(appDirectory, './src'),
|
|
42
42
|
distDirectory: '',
|
|
43
|
-
sharedDirectory:
|
|
44
|
-
nodeModulesDirectory:
|
|
45
|
-
internalDirectory:
|
|
43
|
+
sharedDirectory: _utils.path.resolve(appDirectory, './shared'),
|
|
44
|
+
nodeModulesDirectory: _utils.path.resolve(appDirectory, './node_modules'),
|
|
45
|
+
internalDirectory: _utils.path.resolve(appDirectory, './node_modules/.modern-js'),
|
|
46
46
|
plugins,
|
|
47
47
|
htmlTemplates: {},
|
|
48
48
|
serverRoutes: [],
|
package/dist/js/node/index.js
CHANGED
|
@@ -10,7 +10,6 @@ var _exportNames = {
|
|
|
10
10
|
mountHook: true,
|
|
11
11
|
usePlugins: true,
|
|
12
12
|
cli: true,
|
|
13
|
-
createContext: true,
|
|
14
13
|
defineConfig: true,
|
|
15
14
|
defaultsConfig: true,
|
|
16
15
|
AppContext: true,
|
|
@@ -24,14 +23,7 @@ Object.defineProperty(exports, "AppContext", {
|
|
|
24
23
|
return _context.AppContext;
|
|
25
24
|
}
|
|
26
25
|
});
|
|
27
|
-
exports.cli = void 0;
|
|
28
|
-
Object.defineProperty(exports, "createContext", {
|
|
29
|
-
enumerable: true,
|
|
30
|
-
get: function () {
|
|
31
|
-
return _plugin.createContext;
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
exports.createPlugin = void 0;
|
|
26
|
+
exports.createPlugin = exports.cli = void 0;
|
|
35
27
|
Object.defineProperty(exports, "defaultsConfig", {
|
|
36
28
|
enumerable: true,
|
|
37
29
|
get: function () {
|
|
@@ -65,7 +57,7 @@ Object.defineProperty(exports, "useResolvedConfigContext", {
|
|
|
65
57
|
}
|
|
66
58
|
});
|
|
67
59
|
|
|
68
|
-
var
|
|
60
|
+
var _utils = require("@modern-js/utils");
|
|
69
61
|
|
|
70
62
|
var _plugin = require("@modern-js/plugin");
|
|
71
63
|
|
|
@@ -95,8 +87,6 @@ Object.keys(_node).forEach(function (key) {
|
|
|
95
87
|
});
|
|
96
88
|
});
|
|
97
89
|
|
|
98
|
-
var _utils = require("@modern-js/utils");
|
|
99
|
-
|
|
100
90
|
var _commander = require("./utils/commander");
|
|
101
91
|
|
|
102
92
|
var _config = require("./config");
|
|
@@ -109,8 +99,6 @@ var _initWatcher = require("./initWatcher");
|
|
|
109
99
|
|
|
110
100
|
var _loadEnv = require("./loadEnv");
|
|
111
101
|
|
|
112
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
113
|
-
|
|
114
102
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
115
103
|
|
|
116
104
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
@@ -141,7 +129,7 @@ exports.mountHook = mountHook;
|
|
|
141
129
|
exports.registerHook = registerHook;
|
|
142
130
|
exports.createPlugin = createPlugin;
|
|
143
131
|
|
|
144
|
-
const usePlugins = plugins => plugins.forEach(plugin => manager.usePlugin((0, _utils.compatRequire)(require.resolve(plugin))));
|
|
132
|
+
const usePlugins = plugins => plugins.forEach(plugin => manager.usePlugin((0, _utils.compatRequire)(_utils.upath.normalize(require.resolve(plugin)))));
|
|
145
133
|
|
|
146
134
|
exports.usePlugins = usePlugins;
|
|
147
135
|
|
|
@@ -154,7 +142,7 @@ const initAppDir = async () => {
|
|
|
154
142
|
throw new Error(`no package.json found in current work dir: ${process.cwd()}`);
|
|
155
143
|
}
|
|
156
144
|
|
|
157
|
-
return
|
|
145
|
+
return _utils.path.dirname(pkg);
|
|
158
146
|
};
|
|
159
147
|
|
|
160
148
|
const createCli = () => {
|
|
@@ -5,16 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.initWatcher = void 0;
|
|
7
7
|
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
8
|
var _crypto = _interopRequireDefault(require("crypto"));
|
|
11
9
|
|
|
12
10
|
var _fs = _interopRequireDefault(require("fs"));
|
|
13
11
|
|
|
14
|
-
var _chokidar = _interopRequireDefault(require("chokidar"));
|
|
15
|
-
|
|
16
12
|
var _utils = require("@modern-js/utils");
|
|
17
13
|
|
|
14
|
+
var _chokidar = _interopRequireDefault(require("chokidar"));
|
|
15
|
+
|
|
18
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
17
|
|
|
20
18
|
const debug = (0, _utils.createDebugger)('watch-files');
|
|
@@ -33,7 +31,7 @@ const initWatcher = async (loaded, appDirectory, resovledConfig, hooksRunner, ar
|
|
|
33
31
|
} = resovledConfig;
|
|
34
32
|
const extraFiles = await hooksRunner.watchFiles();
|
|
35
33
|
|
|
36
|
-
const configPath =
|
|
34
|
+
const configPath = _utils.path.join(appDirectory, configDir);
|
|
37
35
|
|
|
38
36
|
const watched = [`${configPath}/html`, ...extraFiles, loaded === null || loaded === void 0 ? void 0 : loaded.filePath, ...loaded.dependencies].filter(Boolean);
|
|
39
37
|
debug(`watched: %o`, watched);
|
|
@@ -46,7 +44,7 @@ const initWatcher = async (loaded, appDirectory, resovledConfig, hooksRunner, ar
|
|
|
46
44
|
|
|
47
45
|
watcher.on('change', changed => {
|
|
48
46
|
const lastHash = hashMap.get(changed);
|
|
49
|
-
const currentHash = md5(_fs.default.readFileSync(
|
|
47
|
+
const currentHash = md5(_fs.default.readFileSync(_utils.path.join(appDirectory, changed), 'utf8'));
|
|
50
48
|
|
|
51
49
|
if (currentHash !== lastHash) {
|
|
52
50
|
debug(`file change: %s`, changed);
|
package/dist/js/node/loadEnv.js
CHANGED
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.loadEnv = void 0;
|
|
7
7
|
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
8
|
var _fs = _interopRequireDefault(require("fs"));
|
|
11
9
|
|
|
10
|
+
var _utils = require("@modern-js/utils");
|
|
11
|
+
|
|
12
12
|
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
13
13
|
|
|
14
14
|
var _dotenvExpand = _interopRequireDefault(require("dotenv-expand"));
|
|
@@ -16,7 +16,7 @@ var _dotenvExpand = _interopRequireDefault(require("dotenv-expand"));
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
|
|
18
18
|
const loadEnv = (appDirectory, mode = process.env.NODE_ENV) => {
|
|
19
|
-
[`.env.${mode}`, '.env'].map(name =>
|
|
19
|
+
[`.env.${mode}`, '.env'].map(name => _utils.path.resolve(appDirectory, name)).filter(filePath => _fs.default.existsSync(filePath) && !_fs.default.statSync(filePath).isDirectory()).forEach(filePath => {
|
|
20
20
|
const envConfig = _dotenv.default.config({
|
|
21
21
|
path: filePath
|
|
22
22
|
});
|
|
@@ -20,9 +20,9 @@ const resolvePlugin = (appDirectory, plugin) => {
|
|
|
20
20
|
let filePath = '';
|
|
21
21
|
|
|
22
22
|
try {
|
|
23
|
-
filePath = require.resolve(name, {
|
|
23
|
+
filePath = _utils.upath.normalizeSafe(require.resolve(name, {
|
|
24
24
|
paths: [appDirectory]
|
|
25
|
-
});
|
|
25
|
+
}));
|
|
26
26
|
delete require.cache[filePath];
|
|
27
27
|
} catch (err) {
|
|
28
28
|
if (err.code === 'MODULE_NOT_FOUND') {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ParallelWorkflow, AsyncWorkflow, Progresses2Runners } from '@modern-js/plugin';
|
|
2
2
|
import type { Hooks } from '@modern-js/types';
|
|
3
3
|
import { Command } from './utils/commander';
|
|
4
4
|
import { defineConfig, UserConfig, ToolsConfig } from './config';
|
|
@@ -72,7 +72,7 @@ export declare const createPlugin: (initializer: import("@modern-js/plugin").Asy
|
|
|
72
72
|
beforeExit: AsyncWorkflow<void, void>;
|
|
73
73
|
} & import("@modern-js/plugin").ClearDraftProgress<Hooks>>;
|
|
74
74
|
export declare const usePlugins: (plugins: string[]) => void;
|
|
75
|
-
export { defineConfig,
|
|
75
|
+
export { defineConfig, AppContext, useAppContext, useConfigContext, useResolvedConfigContext };
|
|
76
76
|
export type { NormalizedConfig, IAppContext, UserConfig, ToolsConfig };
|
|
77
77
|
export interface CoreOption {
|
|
78
78
|
dryRun?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modern-js/core",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.18",
|
|
4
4
|
"jsnext:source": "./src/index.ts",
|
|
5
5
|
"types": "./dist/types/index.d.ts",
|
|
6
6
|
"main": "./dist/js/node/index.js",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@babel/runtime": "^7",
|
|
29
29
|
"@babel/code-frame": "^7.14.5",
|
|
30
|
-
"@modern-js/load-config": "^1.0.0-rc.
|
|
31
|
-
"@modern-js/plugin": "^1.0.0-rc.
|
|
32
|
-
"@modern-js/utils": "^1.0.0-rc.
|
|
30
|
+
"@modern-js/load-config": "^1.0.0-rc.22",
|
|
31
|
+
"@modern-js/plugin": "^1.0.0-rc.18",
|
|
32
|
+
"@modern-js/utils": "^1.0.0-rc.18",
|
|
33
33
|
"address": "^1.1.2",
|
|
34
34
|
"ajv": "^8.6.2",
|
|
35
35
|
"ajv-keywords": "^5.0.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/babel__code-frame": "^7.0.3",
|
|
49
|
-
"@modern-js/types": "^1.0.0-rc.
|
|
49
|
+
"@modern-js/types": "^1.0.0-rc.18",
|
|
50
50
|
"@types/jest": "^26",
|
|
51
51
|
"@types/lodash.clonedeep": "^4.5.6",
|
|
52
52
|
"@types/lodash.mergewith": "^4.6.6",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"@types/react-dom": "^17",
|
|
56
56
|
"@types/signale": "^1.4.2",
|
|
57
57
|
"typescript": "^4",
|
|
58
|
-
"@modern-js/plugin-testing": "^1.0.0-rc.
|
|
59
|
-
"@modern-js/module-tools": "^1.0.0-rc.
|
|
58
|
+
"@modern-js/plugin-testing": "^1.0.0-rc.18",
|
|
59
|
+
"@modern-js/module-tools": "^1.0.0-rc.18"
|
|
60
60
|
},
|
|
61
61
|
"sideEffects": false,
|
|
62
62
|
"modernConfig": {
|
package/src/config/index.ts
CHANGED
|
@@ -107,6 +107,7 @@ export interface ServerConfig {
|
|
|
107
107
|
port?: number;
|
|
108
108
|
logger?: Record<string, string>;
|
|
109
109
|
measure?: Record<string, string>;
|
|
110
|
+
enableMicroFrontendDebug?: boolean;
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
export interface DevConfig {
|
|
@@ -174,7 +175,7 @@ export const loadUserConfig = async (
|
|
|
174
175
|
appDirectory: string,
|
|
175
176
|
filePath?: string,
|
|
176
177
|
): Promise<LoadedConfig> => {
|
|
177
|
-
const loaded = loadConfig<ConfigParam>(appDirectory, filePath);
|
|
178
|
+
const loaded = await loadConfig<ConfigParam>(appDirectory, filePath);
|
|
178
179
|
|
|
179
180
|
const config = !loaded
|
|
180
181
|
? {}
|
package/src/context.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
path,
|
|
3
|
+
upath,
|
|
4
|
+
compatRequire,
|
|
5
|
+
pkgUp,
|
|
6
|
+
ensureAbsolutePath,
|
|
7
|
+
logger,
|
|
8
|
+
} from '@modern-js/utils';
|
|
2
9
|
import {
|
|
3
10
|
createAsyncManager,
|
|
4
|
-
createContext,
|
|
5
11
|
createAsyncWorkflow,
|
|
6
12
|
createParallelWorkflow,
|
|
7
13
|
ParallelWorkflow,
|
|
@@ -9,12 +15,7 @@ import {
|
|
|
9
15
|
Progresses2Runners,
|
|
10
16
|
} from '@modern-js/plugin';
|
|
11
17
|
import { enable } from '@modern-js/plugin/node';
|
|
12
|
-
|
|
13
|
-
compatRequire,
|
|
14
|
-
pkgUp,
|
|
15
|
-
ensureAbsolutePath,
|
|
16
|
-
logger,
|
|
17
|
-
} from '@modern-js/utils';
|
|
18
|
+
|
|
18
19
|
import type { Hooks } from '@modern-js/types';
|
|
19
20
|
import { program, Command } from './utils/commander';
|
|
20
21
|
import {
|
|
@@ -104,12 +105,11 @@ export const {
|
|
|
104
105
|
|
|
105
106
|
export const usePlugins = (plugins: string[]) =>
|
|
106
107
|
plugins.forEach(plugin =>
|
|
107
|
-
manager.usePlugin(compatRequire(require.resolve(plugin))),
|
|
108
|
+
manager.usePlugin(compatRequire(upath.normalize(require.resolve(plugin)))),
|
|
108
109
|
);
|
|
109
110
|
|
|
110
111
|
export {
|
|
111
112
|
defineConfig,
|
|
112
|
-
createContext,
|
|
113
113
|
AppContext,
|
|
114
114
|
useAppContext,
|
|
115
115
|
useConfigContext,
|
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 '.';
|
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