@shuvi/service 1.0.8 → 1.0.10
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/lib/analysis/index.js +2 -2
- package/lib/bundler/bundler.d.ts +1 -1
- package/lib/bundler/bundler.js +3 -3
- package/lib/bundler/typescript/checkDependencies.js +2 -2
- package/lib/bundler/typescript/configTypeScript.js +2 -2
- package/lib/bundler/typescript/getTsConfig.js +3 -3
- package/lib/bundler/typescript/installDependencies.js +1 -1
- package/lib/bundler/typescript/setupTypeScript.js +1 -1
- package/lib/config/config.js +2 -2
- package/lib/config/env.js +1 -1
- package/lib/constants.d.ts +1 -1
- package/lib/constants.js +1 -1
- package/lib/core/api.d.ts +4 -4
- package/lib/core/api.js +5 -5
- package/lib/core/apiTypes.d.ts +2 -2
- package/lib/core/getPlugins.js +3 -4
- package/lib/core/paths.js +1 -1
- package/lib/core/plugin.d.ts +3 -3
- package/lib/core/plugin.js +1 -1
- package/lib/project/file-builder/fileBuilder.d.ts +3 -3
- package/lib/project/file-builder/fileBuilder.js +2 -2
- package/lib/project/file-builder/types.d.ts +4 -4
- package/lib/project/file-presets/files/app/shuvi-app.d.ts.js +1 -1
- package/lib/project/file-presets/index.d.ts +3 -3
- package/lib/project/file-utils/utils.js +5 -5
- package/lib/project/projectBuilder.d.ts +3 -3
- package/lib/project/projectBuilder.js +1 -1
- package/lib/resources.js +1 -1
- package/lib/server/http-server/router.js +1 -1
- package/lib/server/http-server/server.js +1 -1
- package/lib/server/middlewares/dev/devMiddleware.js +1 -1
- package/lib/server/middlewares/dev/hotMiddleware.js +1 -1
- package/lib/server/plugin.d.ts +1 -1
- package/lib/server/plugin.js +1 -1
- package/lib/server/serverMiddleware.js +1 -1
- package/lib/server/shuviDevServer.js +2 -2
- package/lib/server/shuviServer.js +1 -1
- package/package.json +10 -10
package/lib/analysis/index.js
CHANGED
|
@@ -38,9 +38,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
38
38
|
exports.analysis = void 0;
|
|
39
39
|
const path = __importStar(require("path"));
|
|
40
40
|
const fs = __importStar(require("fs"));
|
|
41
|
-
const logger_1 = __importDefault(require("@shuvi/utils/
|
|
41
|
+
const logger_1 = __importDefault(require("@shuvi/utils/logger"));
|
|
42
42
|
const events_1 = require("./events");
|
|
43
|
-
const recursiveReaddir_1 = require("@shuvi/utils/
|
|
43
|
+
const recursiveReaddir_1 = require("@shuvi/utils/recursiveReaddir");
|
|
44
44
|
const typescript_1 = require("../bundler/typescript");
|
|
45
45
|
const analysis = ({ context, telemetry }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
46
|
var _a, _b;
|
package/lib/bundler/bundler.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RemoveListenerCallback } from '@shuvi/utils/
|
|
1
|
+
import { RemoveListenerCallback } from '@shuvi/utils/events';
|
|
2
2
|
import { Compiler as WebapckCompiler } from '@shuvi/toolpack/lib/webpack';
|
|
3
3
|
import { Server } from '../server';
|
|
4
4
|
import { IPluginContext } from '../core';
|
package/lib/bundler/bundler.js
CHANGED
|
@@ -37,14 +37,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.getBundler = void 0;
|
|
39
39
|
const path_1 = __importDefault(require("path"));
|
|
40
|
-
const events_1 = require("@shuvi/utils/
|
|
40
|
+
const events_1 = require("@shuvi/utils/events");
|
|
41
41
|
const forkTsCheckerWebpackPlugin_1 = __importStar(require("@shuvi/toolpack/lib/utils/forkTsCheckerWebpackPlugin"));
|
|
42
42
|
const formatWebpackMessages_1 = __importDefault(require("@shuvi/toolpack/lib/utils/formatWebpackMessages"));
|
|
43
|
-
const logger_1 = __importDefault(require("@shuvi/utils/
|
|
43
|
+
const logger_1 = __importDefault(require("@shuvi/utils/logger"));
|
|
44
44
|
const util_1 = require("util");
|
|
45
45
|
const webpack_1 = require("@shuvi/toolpack/lib/webpack");
|
|
46
46
|
const config_1 = require("@shuvi/toolpack/lib/webpack/config");
|
|
47
|
-
const constants_1 = require("@shuvi/shared/
|
|
47
|
+
const constants_1 = require("@shuvi/shared/constants");
|
|
48
48
|
const error_1 = require("../error");
|
|
49
49
|
const config_2 = require("./config");
|
|
50
50
|
const runCompiler_1 = require("./runCompiler");
|
|
@@ -11,8 +11,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.checkNecessaryDeps = exports.hasTypescriptFiles = exports.resolveDependencies = void 0;
|
|
13
13
|
const fs_extra_1 = require("fs-extra");
|
|
14
|
-
const resolve_1 = require("@shuvi/utils/
|
|
15
|
-
const recursiveReaddir_1 = require("@shuvi/utils/
|
|
14
|
+
const resolve_1 = require("@shuvi/utils/resolve");
|
|
15
|
+
const recursiveReaddir_1 = require("@shuvi/utils/recursiveReaddir");
|
|
16
16
|
const requiredPackages = [
|
|
17
17
|
{ file: 'typescript', pkg: 'typescript' },
|
|
18
18
|
{ file: '@types/react/index.d.ts', pkg: '@types/react' },
|
|
@@ -36,8 +36,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.writeDefaultConfigurations = void 0;
|
|
39
|
-
const chalk_1 = __importDefault(require("@shuvi/utils/
|
|
40
|
-
const isEqual_1 = __importDefault(require("@shuvi/utils/
|
|
39
|
+
const chalk_1 = __importDefault(require("@shuvi/utils/chalk"));
|
|
40
|
+
const isEqual_1 = __importDefault(require("@shuvi/utils/isEqual"));
|
|
41
41
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
42
42
|
const CommentJson = __importStar(require("comment-json"));
|
|
43
43
|
const os_1 = __importDefault(require("os"));
|
|
@@ -16,9 +16,9 @@ exports.getTsConfig = exports.hasTsConfig = exports.hasTypescriptFiles = void 0;
|
|
|
16
16
|
const fs_extra_1 = require("fs-extra");
|
|
17
17
|
const os_1 = __importDefault(require("os"));
|
|
18
18
|
const path_1 = __importDefault(require("path"));
|
|
19
|
-
const chalk_1 = __importDefault(require("@shuvi/utils/
|
|
20
|
-
const logger_1 = __importDefault(require("@shuvi/utils/
|
|
21
|
-
const recursiveReaddir_1 = require("@shuvi/utils/
|
|
19
|
+
const chalk_1 = __importDefault(require("@shuvi/utils/chalk"));
|
|
20
|
+
const logger_1 = __importDefault(require("@shuvi/utils/logger"));
|
|
21
|
+
const recursiveReaddir_1 = require("@shuvi/utils/recursiveReaddir");
|
|
22
22
|
function hasTypescriptFiles(projectDir) {
|
|
23
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
24
|
try {
|
|
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.installDependencies = exports.install = void 0;
|
|
39
|
-
const chalk_1 = __importDefault(require("@shuvi/utils/
|
|
39
|
+
const chalk_1 = __importDefault(require("@shuvi/utils/chalk"));
|
|
40
40
|
const cross_spawn_1 = __importDefault(require("cross-spawn"));
|
|
41
41
|
const path = __importStar(require("path"));
|
|
42
42
|
const getPkgManager_1 = require("../helper/getPkgManager");
|
|
@@ -37,7 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.setupTypeScript = exports.loadJsConfig = exports.getJavaScriptInfo = void 0;
|
|
39
39
|
const path = __importStar(require("path"));
|
|
40
|
-
const chalk_1 = __importDefault(require("@shuvi/utils/
|
|
40
|
+
const chalk_1 = __importDefault(require("@shuvi/utils/chalk"));
|
|
41
41
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
42
42
|
const error_1 = require("../../error");
|
|
43
43
|
const getPkgManager_1 = require("../helper/getPkgManager");
|
package/lib/config/config.js
CHANGED
|
@@ -16,8 +16,8 @@ exports.loadConfig = void 0;
|
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
17
|
const fs_1 = __importDefault(require("fs"));
|
|
18
18
|
const bundleRequire_1 = require("@shuvi/toolpack/lib/utils/bundleRequire");
|
|
19
|
-
const file_1 = require("@shuvi/utils/
|
|
20
|
-
const logger_1 = __importDefault(require("@shuvi/utils/
|
|
19
|
+
const file_1 = require("@shuvi/utils/file");
|
|
20
|
+
const logger_1 = __importDefault(require("@shuvi/utils/logger"));
|
|
21
21
|
const constants_1 = require("../constants");
|
|
22
22
|
const env_1 = require("./env");
|
|
23
23
|
const validExts = ['.ts', '.tsx', '.js', '.jsx', '.cjs', '.mjs'];
|
package/lib/config/env.js
CHANGED
|
@@ -32,7 +32,7 @@ const dotenv = __importStar(require("dotenv"));
|
|
|
32
32
|
const dotenv_expand_1 = require("dotenv-expand");
|
|
33
33
|
const fs = __importStar(require("fs"));
|
|
34
34
|
const path = __importStar(require("path"));
|
|
35
|
-
const logger_1 = __importDefault(require("@shuvi/utils/
|
|
35
|
+
const logger_1 = __importDefault(require("@shuvi/utils/logger"));
|
|
36
36
|
let initialEnv = undefined;
|
|
37
37
|
let combinedEnv = undefined;
|
|
38
38
|
let cachedLoadedEnvFiles = [];
|
package/lib/constants.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { CLIENT_OUTPUT_DIR, SERVER_OUTPUT_DIR } from '@shuvi/shared/
|
|
1
|
+
export { CLIENT_OUTPUT_DIR, SERVER_OUTPUT_DIR } from '@shuvi/shared/constants';
|
|
2
2
|
export declare const CONFIG_FILE = "shuvi.config";
|
|
3
3
|
export declare const DEFAULT_PUBLIC_PATH = "/";
|
|
4
4
|
export declare const PUBLIC_DIR_NAME = "public";
|
package/lib/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PHASE_INSPECT_WEBPACK = exports.PHASE_DEVELOPMENT_SERVER = exports.PHASE_PRODUCTION_SERVER = exports.PHASE_PRODUCTION_BUILD = exports.PUBLIC_DIR_NAME = exports.DEFAULT_PUBLIC_PATH = exports.CONFIG_FILE = exports.SERVER_OUTPUT_DIR = exports.CLIENT_OUTPUT_DIR = void 0;
|
|
4
|
-
var constants_1 = require("@shuvi/shared/
|
|
4
|
+
var constants_1 = require("@shuvi/shared/constants");
|
|
5
5
|
Object.defineProperty(exports, "CLIENT_OUTPUT_DIR", { enumerable: true, get: function () { return constants_1.CLIENT_OUTPUT_DIR; } });
|
|
6
6
|
Object.defineProperty(exports, "SERVER_OUTPUT_DIR", { enumerable: true, get: function () { return constants_1.SERVER_OUTPUT_DIR; } });
|
|
7
7
|
exports.CONFIG_FILE = 'shuvi.config';
|
package/lib/core/api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Telemetry as TelemetryImpl, RecordObject, TelemetryEvent } from '@shuvi/telemetry';
|
|
2
|
-
import {
|
|
2
|
+
import { FileOptionWithId } from '../project';
|
|
3
3
|
import { Bundler } from '../bundler';
|
|
4
4
|
import { ServerPluginInstance } from '../server';
|
|
5
5
|
import { ShuviConfig, IPluginConfig, IPresetConfig, IServiceMode, IServicePhase, IPlatform, IPlatformContent, IPluginContext, RuntimePluginConfig } from './apiTypes';
|
|
@@ -52,7 +52,7 @@ declare class Api {
|
|
|
52
52
|
constructor({ cwd, mode, config, configFile, presets, plugins, phase, platform, normalizePlatformConfig, telemetry }: IApiOPtions);
|
|
53
53
|
get cwd(): string;
|
|
54
54
|
get mode(): IServiceMode;
|
|
55
|
-
get pluginManager(): import("@shuvi/hook
|
|
55
|
+
get pluginManager(): import("@shuvi/hook").HookManager<import("./plugin").PluginHooks, IPluginContext>;
|
|
56
56
|
get pluginContext(): IPluginContext;
|
|
57
57
|
get serverConfigs(): ServerConfigs;
|
|
58
58
|
get telemetry(): Telemetry;
|
|
@@ -60,8 +60,8 @@ declare class Api {
|
|
|
60
60
|
getBundler(): Promise<Bundler>;
|
|
61
61
|
get assetPublicPath(): string;
|
|
62
62
|
buildApp(): Promise<void>;
|
|
63
|
-
addRuntimeFile(option:
|
|
64
|
-
addInternalRuntimeFile(option:
|
|
63
|
+
addRuntimeFile(option: FileOptionWithId<any>): void;
|
|
64
|
+
addInternalRuntimeFile(option: FileOptionWithId<any>): void;
|
|
65
65
|
addRuntimePlugin(plugin: RuntimePluginConfig): void;
|
|
66
66
|
addRuntimeService(source: string, exported: string, filepath?: string): void;
|
|
67
67
|
addRuntimeTypesPatch(file: string): void;
|
package/lib/core/api.js
CHANGED
|
@@ -36,10 +36,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.getApi = exports.Api = void 0;
|
|
39
|
-
const
|
|
40
|
-
const deepmerge_1 = require("@shuvi/utils/
|
|
41
|
-
const string_1 = require("@shuvi/utils/
|
|
42
|
-
const logger_1 = __importDefault(require("@shuvi/utils/
|
|
39
|
+
const hook_1 = require("@shuvi/hook");
|
|
40
|
+
const deepmerge_1 = require("@shuvi/utils/deepmerge");
|
|
41
|
+
const string_1 = require("@shuvi/utils/string");
|
|
42
|
+
const logger_1 = __importDefault(require("@shuvi/utils/logger"));
|
|
43
43
|
const rimraf_1 = __importDefault(require("rimraf"));
|
|
44
44
|
const path = __importStar(require("path"));
|
|
45
45
|
const project_1 = require("../project");
|
|
@@ -317,7 +317,7 @@ class Api {
|
|
|
317
317
|
if (typeof plugin === 'string') {
|
|
318
318
|
resolvedPlugins.push((0, getPlugins_1.resolvePlugin)(plugin));
|
|
319
319
|
}
|
|
320
|
-
else if ((0,
|
|
320
|
+
else if ((0, hook_1.isPluginInstance)(plugin)) {
|
|
321
321
|
resolvedPlugins.push({ core: plugin });
|
|
322
322
|
}
|
|
323
323
|
else {
|
package/lib/core/apiTypes.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CompilerOptions } from '@shuvi/toolpack/lib/webpack/loaders/shuvi-swc-loader';
|
|
2
2
|
import { CorePluginConstructor, CorePluginFactory, CorePluginInstance, PluginRunner } from './plugin';
|
|
3
|
-
import {
|
|
3
|
+
import { FileOptionWithId } from '../project';
|
|
4
4
|
import { IProxyConfig } from '../server/middlewares/httpProxyMiddleware';
|
|
5
5
|
import { IServerMiddleware, IServerPluginContext, ServerPluginInstance, ServerPluginConstructor, ServerPluginFactory } from '../server';
|
|
6
6
|
import { DevMiddleware } from '../server/middlewares/dev';
|
|
@@ -58,7 +58,7 @@ export interface ResolvedPlugin {
|
|
|
58
58
|
export declare type IPlatformContent = {
|
|
59
59
|
types?: string | string[];
|
|
60
60
|
plugins?: (CorePluginInstance | ResolvedPlugin | string)[];
|
|
61
|
-
getPresetRuntimeFiles: (context: IPluginContext) =>
|
|
61
|
+
getPresetRuntimeFiles: (context: IPluginContext) => FileOptionWithId<any>[] | Promise<FileOptionWithId<any>[]>;
|
|
62
62
|
getMiddlewares?: (context: IServerPluginContext) => Promise<IServerMiddleware | IServerMiddleware[]>;
|
|
63
63
|
getMiddlewaresBeforeDevMiddlewares?: (devMiddleware: DevMiddleware, context: IServerPluginContext) => IServerMiddleware | IServerMiddleware[];
|
|
64
64
|
};
|
package/lib/core/getPlugins.js
CHANGED
|
@@ -27,9 +27,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.getPlugins = exports.resolvePresets = exports.resolvePlugins = exports.resolvePreset = exports.resolvePlugin = void 0;
|
|
30
|
-
const invariant_1 = __importDefault(require("@shuvi/utils/
|
|
30
|
+
const invariant_1 = __importDefault(require("@shuvi/utils/invariant"));
|
|
31
31
|
const hook_1 = require("@shuvi/hook");
|
|
32
|
-
const logger_1 = __importDefault(require("@shuvi/utils/
|
|
32
|
+
const logger_1 = __importDefault(require("@shuvi/utils/logger"));
|
|
33
33
|
const path = __importStar(require("path"));
|
|
34
34
|
const plugin_1 = require("./plugin");
|
|
35
35
|
const plugin_2 = require("../server/plugin");
|
|
@@ -232,8 +232,7 @@ function resolvePlugin(pluginConfig, resolveOptions) {
|
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
if (typesPath) {
|
|
235
|
-
|
|
236
|
-
resolved.types = dir + path.sep + 'types';
|
|
235
|
+
resolved.types = typesPath;
|
|
237
236
|
}
|
|
238
237
|
}
|
|
239
238
|
return resolved;
|
package/lib/core/paths.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getPaths = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
|
-
const constants_1 = require("@shuvi/shared/
|
|
5
|
+
const constants_1 = require("@shuvi/shared/constants");
|
|
6
6
|
const constants_2 = require("../constants");
|
|
7
7
|
function getPaths(opts) {
|
|
8
8
|
const { rootDir, outputPath } = opts;
|
package/lib/core/plugin.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IPluginInstance, IPluginHandlers } from '@shuvi/hook';
|
|
2
|
-
import {
|
|
2
|
+
import { FileOptionWithId } from '../project/index';
|
|
3
3
|
import { ExtraTargetAssistant, ConfigWebpackAssistant, TargetChain, BundlerDoneExtra, BundlerTargetDoneExtra, RuntimeService, Resources, AddRuntimeFileUtils, WebpackChainType } from './pluginTypes';
|
|
4
4
|
import { ShuviConfig, IPluginContext, CustomCorePluginHooks } from './apiTypes';
|
|
5
5
|
declare const builtinPluginHooks: {
|
|
@@ -12,7 +12,7 @@ declare const builtinPluginHooks: {
|
|
|
12
12
|
configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<WebpackChainType, ConfigWebpackAssistant>;
|
|
13
13
|
addExtraTarget: import("@shuvi/hook").AsyncParallelHook<ExtraTargetAssistant, void, TargetChain>;
|
|
14
14
|
addResource: import("@shuvi/hook").AsyncParallelHook<void, void, Resources | Resources[]>;
|
|
15
|
-
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, AddRuntimeFileUtils,
|
|
15
|
+
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, AddRuntimeFileUtils, FileOptionWithId<any, any> | FileOptionWithId<any, any>[]>;
|
|
16
16
|
addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, RuntimeService | RuntimeService[]>;
|
|
17
17
|
};
|
|
18
18
|
export * from './pluginTypes';
|
|
@@ -25,4 +25,4 @@ export declare type CorePluginFactory = (options: any) => CorePluginInstance;
|
|
|
25
25
|
export declare const getManager: () => import("@shuvi/hook").HookManager<PluginHooks, IPluginContext>;
|
|
26
26
|
export declare type PluginManager = ReturnType<typeof getManager>;
|
|
27
27
|
export declare type PluginRunner = PluginManager['runner'];
|
|
28
|
-
export declare const createPluginBefore: import("@shuvi/shared/
|
|
28
|
+
export declare const createPluginBefore: import("@shuvi/shared/plugins").PluginFunc<PluginHooks, IPluginContext>, createPlugin: import("@shuvi/shared/plugins").PluginFunc<PluginHooks, IPluginContext>, createPluginAfter: import("@shuvi/shared/plugins").PluginFunc<PluginHooks, IPluginContext>;
|
package/lib/core/plugin.js
CHANGED
|
@@ -17,7 +17,7 @@ var _a;
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.createPluginAfter = exports.createPlugin = exports.createPluginBefore = exports.getManager = void 0;
|
|
19
19
|
const hook_1 = require("@shuvi/hook");
|
|
20
|
-
const plugins_1 = require("@shuvi/shared/
|
|
20
|
+
const plugins_1 = require("@shuvi/shared/plugins");
|
|
21
21
|
const extendConfig = (0, hook_1.createSyncWaterfallHook)();
|
|
22
22
|
const afterInit = (0, hook_1.createAsyncParallelHook)();
|
|
23
23
|
const afterBuild = (0, hook_1.createAsyncParallelHook)();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FileOptionWithId, FileInfo } from './types';
|
|
2
2
|
declare type OnBuildStartEvent = {};
|
|
3
3
|
declare type OnSingleBuildEndEvent = {
|
|
4
4
|
finished: boolean;
|
|
@@ -12,11 +12,11 @@ declare type OnSingleBuildEndHandler = (event: OnSingleBuildEndEvent) => void;
|
|
|
12
12
|
declare type OnBuildEndHandler = (event: OnBuildEndEvent) => void;
|
|
13
13
|
declare type EventCanceler = () => void;
|
|
14
14
|
export interface FileBuilder<C extends {}> {
|
|
15
|
-
addFile: (...newFileOption:
|
|
15
|
+
addFile: (...newFileOption: FileOptionWithId<any, C>[]) => void;
|
|
16
16
|
build: (dir?: string) => Promise<void>;
|
|
17
17
|
watch: (dir?: string) => Promise<void>;
|
|
18
18
|
close: () => Promise<void>;
|
|
19
|
-
getContent: <T>(fileOption:
|
|
19
|
+
getContent: <T>(fileOption: FileOptionWithId<T>) => T;
|
|
20
20
|
onBuildStart: (eventHandler: OnBuildStartHandler) => EventCanceler;
|
|
21
21
|
onBuildEnd: (eventHandler: OnBuildEndHandler) => EventCanceler;
|
|
22
22
|
onSingleBuildEnd: (eventHandler: OnSingleBuildEndHandler) => EventCanceler;
|
|
@@ -36,11 +36,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.getFileBuilder = void 0;
|
|
39
|
-
const invariant_1 = __importDefault(require("@shuvi/utils/
|
|
39
|
+
const invariant_1 = __importDefault(require("@shuvi/utils/invariant"));
|
|
40
40
|
const utils_1 = require("@shuvi/utils");
|
|
41
41
|
const fs = __importStar(require("fs-extra"));
|
|
42
42
|
const path = __importStar(require("path"));
|
|
43
|
-
const fileWatcher_1 = require("@shuvi/utils/
|
|
43
|
+
const fileWatcher_1 = require("@shuvi/utils/fileWatcher");
|
|
44
44
|
const utils_2 = require("./utils");
|
|
45
45
|
const constants_1 = require("./constants");
|
|
46
46
|
const helpers_1 = require("./helpers");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare type FileId = string;
|
|
2
2
|
export declare type ContentFunction<T, C> = (context: C, oldContent: T) => T | Promise<T>;
|
|
3
|
-
export declare type FileDependency = string |
|
|
4
|
-
export interface
|
|
3
|
+
export declare type FileDependency = string | FileOptionWithId<any>;
|
|
4
|
+
export interface FileOptionWithId<T = string, C = any> {
|
|
5
5
|
id: FileId;
|
|
6
6
|
content: ContentFunction<T, C>;
|
|
7
7
|
name?: string;
|
|
@@ -11,7 +11,7 @@ export interface FileOption<T = string, C = any> {
|
|
|
11
11
|
ignoreFileContentUpdate: boolean;
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
export declare type
|
|
14
|
+
export declare type FileOption<T = string, C = any> = Omit<FileOptionWithId<T, C>, 'id'>;
|
|
15
15
|
export interface FileInternalInstance<T = string, C = any> {
|
|
16
16
|
id: FileId;
|
|
17
17
|
content: ContentFunction<T, C>;
|
|
@@ -20,7 +20,7 @@ export interface FileInternalInstance<T = string, C = any> {
|
|
|
20
20
|
virtual?: boolean;
|
|
21
21
|
fileContent?: T;
|
|
22
22
|
}
|
|
23
|
-
export declare type DefineFile = <T = string, C = any>(fileOption:
|
|
23
|
+
export declare type DefineFile = <T = string, C = any>(fileOption: FileOption<T, C>) => FileOptionWithId<T, C>;
|
|
24
24
|
export declare type DependencyInfo = {
|
|
25
25
|
dependencies: Set<FileId>;
|
|
26
26
|
dependents: Set<FileId>;
|
|
@@ -6,7 +6,7 @@ exports.default = (0, __1.defineFile)({
|
|
|
6
6
|
const types = context.typeDeclarationFiles;
|
|
7
7
|
return types
|
|
8
8
|
.map(file => {
|
|
9
|
-
const isPath = file
|
|
9
|
+
const isPath = /\.d\.ts$/.test(file) || file.startsWith('.');
|
|
10
10
|
return isPath
|
|
11
11
|
? `/// <reference path="${file}" />`
|
|
12
12
|
: `/// <reference types="${file}" />`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function getFilePresets():
|
|
3
|
-
export declare type FileOptionWithoutName = Omit<
|
|
1
|
+
import { FileOptionWithId, FileOption } from '../file-builder';
|
|
2
|
+
export declare function getFilePresets(): FileOptionWithId<any, any>[];
|
|
3
|
+
export declare type FileOptionWithoutName = Omit<FileOption, 'name'>;
|
|
4
4
|
export declare const defineFile: (options: FileOptionWithoutName) => FileOptionWithoutName;
|
|
@@ -26,8 +26,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.getExportsFromObject = exports.getContentProxyObj = exports.getUserCustomFileCandidates = exports.getFirstModuleExport = exports.getModuleExport = exports.getAllFiles = void 0;
|
|
27
27
|
const fs = __importStar(require("fs"));
|
|
28
28
|
const path = __importStar(require("path"));
|
|
29
|
-
const recursiveReaddir_1 = require("@shuvi/utils/
|
|
30
|
-
const file_1 = require("@shuvi/utils/
|
|
29
|
+
const recursiveReaddir_1 = require("@shuvi/utils/recursiveReaddir");
|
|
30
|
+
const file_1 = require("@shuvi/utils/file");
|
|
31
31
|
const getAllFiles = (dependencies) => {
|
|
32
32
|
const allFiles = [];
|
|
33
33
|
const fileDependencies = Array.isArray(dependencies)
|
|
@@ -72,9 +72,9 @@ const getUserCustomFileCandidates = (rootPath, fileName, fallbackType) => {
|
|
|
72
72
|
const SRC_DIR = 'src';
|
|
73
73
|
const moduleFileExtensions = ['.ts', '.tsx', '.js', '.jsx'];
|
|
74
74
|
const fallbackMap = {
|
|
75
|
-
nullish: require.resolve('@shuvi/utils/
|
|
76
|
-
noop: require.resolve('@shuvi/utils/
|
|
77
|
-
noopFn: require.resolve('@shuvi/utils/
|
|
75
|
+
nullish: require.resolve('@shuvi/utils/nullish'),
|
|
76
|
+
noop: require.resolve('@shuvi/utils/noop'),
|
|
77
|
+
noopFn: require.resolve('@shuvi/utils/noopFn')
|
|
78
78
|
};
|
|
79
79
|
const fallback = fallbackMap[fallbackType] || fallbackMap['nullish'];
|
|
80
80
|
return [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RuntimePluginConfig } from '../core';
|
|
2
|
-
import {
|
|
2
|
+
import { FileOptionWithId } from './file-builder';
|
|
3
3
|
declare class ProjectBuilder {
|
|
4
4
|
private _projectContext;
|
|
5
5
|
private _fileBuilder;
|
|
@@ -12,11 +12,11 @@ declare class ProjectBuilder {
|
|
|
12
12
|
/**
|
|
13
13
|
* default path is the root path
|
|
14
14
|
*/
|
|
15
|
-
addFile(option:
|
|
15
|
+
addFile(option: FileOptionWithId<any, any>): void;
|
|
16
16
|
build(dir: string): Promise<void>;
|
|
17
17
|
watch(dir: string): Promise<void>;
|
|
18
18
|
stopBuild(): Promise<void>;
|
|
19
|
-
get getContent(): <T>(fileOption:
|
|
19
|
+
get getContent(): <T>(fileOption: FileOptionWithId<T, any>) => T;
|
|
20
20
|
get onBuildStart(): (eventHandler: (event: {}) => void) => () => void;
|
|
21
21
|
get onBuildEnd(): (eventHandler: (event: {
|
|
22
22
|
changedFiles: ReadonlyMap<string, import("./file-builder").FileInfo>;
|
|
@@ -37,7 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.ProjectBuilder = void 0;
|
|
39
39
|
const path = __importStar(require("path"));
|
|
40
|
-
const invariant_1 = __importDefault(require("@shuvi/utils/
|
|
40
|
+
const invariant_1 = __importDefault(require("@shuvi/utils/invariant"));
|
|
41
41
|
const file_presets_1 = require("./file-presets");
|
|
42
42
|
const file_utils_1 = require("./file-utils");
|
|
43
43
|
const projectContext_1 = require("./projectContext");
|
package/lib/resources.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports._setResourceEnv = void 0;
|
|
7
|
-
const logger_1 = __importDefault(require("@shuvi/utils/
|
|
7
|
+
const logger_1 = __importDefault(require("@shuvi/utils/logger"));
|
|
8
8
|
let isCached = false;
|
|
9
9
|
let requireTarget = '';
|
|
10
10
|
const cache = {};
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getRouter = void 0;
|
|
7
7
|
const util_1 = require("util");
|
|
8
8
|
const utils_1 = require("@shuvi/utils");
|
|
9
|
-
const invariant_1 = __importDefault(require("@shuvi/utils/
|
|
9
|
+
const invariant_1 = __importDefault(require("@shuvi/utils/invariant"));
|
|
10
10
|
const router_1 = require("@shuvi/router");
|
|
11
11
|
class RouterImpl {
|
|
12
12
|
constructor(options) {
|
|
@@ -39,7 +39,7 @@ exports.Server = void 0;
|
|
|
39
39
|
const http = __importStar(require("http"));
|
|
40
40
|
const url_1 = require("url");
|
|
41
41
|
const router_1 = require("@shuvi/router");
|
|
42
|
-
const logger_1 = __importDefault(require("@shuvi/utils/
|
|
42
|
+
const logger_1 = __importDefault(require("@shuvi/utils/logger"));
|
|
43
43
|
const detect_port_1 = __importDefault(require("detect-port"));
|
|
44
44
|
const utils_1 = require("../utils");
|
|
45
45
|
const router_2 = require("./router");
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getDevMiddleware = void 0;
|
|
7
7
|
const ws_1 = __importDefault(require("ws"));
|
|
8
|
-
const constants_1 = require("@shuvi/shared/
|
|
8
|
+
const constants_1 = require("@shuvi/shared/constants");
|
|
9
9
|
const middleware_1 = require("@shuvi/error-overlay/lib/middleware");
|
|
10
10
|
const constants_2 = require("../../../constants");
|
|
11
11
|
const hotMiddleware_1 = require("./hotMiddleware");
|
|
@@ -8,7 +8,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.WebpackHotMiddleware = void 0;
|
|
10
10
|
const module_replace_plugin_1 = __importDefault(require("@shuvi/toolpack/lib/webpack/plugins/module-replace-plugin"));
|
|
11
|
-
const constants_1 = require("@shuvi/shared/
|
|
11
|
+
const constants_1 = require("@shuvi/shared/constants");
|
|
12
12
|
const modulesActivity = new Map();
|
|
13
13
|
const routesActivity = new Map();
|
|
14
14
|
const activePages = new Set();
|
package/lib/server/plugin.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export interface BuiltInServerPluginHooks extends HookMap {
|
|
|
17
17
|
export interface ServerPluginHooks extends BuiltInServerPluginHooks, CustomServerPluginHooks {
|
|
18
18
|
}
|
|
19
19
|
export declare const getManager: () => import("@shuvi/hook").HookManager<ServerPluginHooks, IServerPluginContext>;
|
|
20
|
-
export declare const createServerPluginBefore: import("@shuvi/shared/
|
|
20
|
+
export declare const createServerPluginBefore: import("@shuvi/shared/plugins").PluginFunc<ServerPluginHooks, IServerPluginContext>, createServerPlugin: import("@shuvi/shared/plugins").PluginFunc<ServerPluginHooks, IServerPluginContext>, createServerPluginAfter: import("@shuvi/shared/plugins").PluginFunc<ServerPluginHooks, IServerPluginContext>;
|
|
21
21
|
export declare type ServerPluginConstructor = IPluginHandlers<ServerPluginHooks, IServerPluginContext>;
|
|
22
22
|
export declare type ServerPluginInstance = IPluginInstance<ServerPluginHooks, IServerPluginContext>;
|
|
23
23
|
export declare type ServerPluginFactory = (options: any) => ServerPluginInstance;
|
package/lib/server/plugin.js
CHANGED
|
@@ -17,7 +17,7 @@ var _a;
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.initServerPlugins = exports.createServerPluginAfter = exports.createServerPlugin = exports.createServerPluginBefore = exports.getManager = void 0;
|
|
19
19
|
const hook_1 = require("@shuvi/hook");
|
|
20
|
-
const plugins_1 = require("@shuvi/shared/
|
|
20
|
+
const plugins_1 = require("@shuvi/shared/plugins");
|
|
21
21
|
__exportStar(require("./pluginTypes"), exports);
|
|
22
22
|
const listen = (0, hook_1.createAsyncParallelHook)();
|
|
23
23
|
const internalHooks = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeServerMiddleware = void 0;
|
|
4
|
-
const resolve_1 = require("@shuvi/utils/
|
|
4
|
+
const resolve_1 = require("@shuvi/utils/resolve");
|
|
5
5
|
function resolveHandler(handler, options) {
|
|
6
6
|
try {
|
|
7
7
|
// Note: check if it is a npm module
|
|
@@ -21,8 +21,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.ShuviDevServer = void 0;
|
|
24
|
-
const constants_1 = require("@shuvi/shared/
|
|
25
|
-
const fileWatcher_1 = require("@shuvi/utils/
|
|
24
|
+
const constants_1 = require("@shuvi/shared/constants");
|
|
25
|
+
const fileWatcher_1 = require("@shuvi/utils/fileWatcher");
|
|
26
26
|
const config_1 = require("@shuvi/toolpack/lib/webpack/config");
|
|
27
27
|
const path_1 = require("path");
|
|
28
28
|
const typescript_1 = require("../bundler/typescript");
|
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ShuviServer = void 0;
|
|
13
|
-
const string_1 = require("@shuvi/utils/
|
|
13
|
+
const string_1 = require("@shuvi/utils/string");
|
|
14
14
|
const serverMiddleware_1 = require("./serverMiddleware");
|
|
15
15
|
const http_server_1 = require("./http-server");
|
|
16
16
|
const plugin_1 = require("./plugin");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuvi/service",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/shuvijs/shuvi.git",
|
|
@@ -22,21 +22,21 @@
|
|
|
22
22
|
"build": "tsc -p tsconfig.build.json -m commonjs"
|
|
23
23
|
},
|
|
24
24
|
"engines": {
|
|
25
|
-
"node": ">=
|
|
25
|
+
"node": ">= 16.0.0"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@babel/code-frame": "7.14.5",
|
|
29
29
|
"@babel/generator": "7.14.5",
|
|
30
30
|
"@babel/parser": "7.14.7",
|
|
31
31
|
"@babel/traverse": "7.14.7",
|
|
32
|
-
"@shuvi/hook": "1.0.
|
|
33
|
-
"@shuvi/router": "1.0.
|
|
34
|
-
"@shuvi/runtime": "1.0.
|
|
35
|
-
"@shuvi/shared": "1.0.
|
|
36
|
-
"@shuvi/toolpack": "1.0.
|
|
37
|
-
"@shuvi/utils": "1.0.
|
|
38
|
-
"@shuvi/error-overlay": "1.0.
|
|
39
|
-
"@shuvi/telemetry": "1.0.
|
|
32
|
+
"@shuvi/hook": "1.0.10",
|
|
33
|
+
"@shuvi/router": "1.0.10",
|
|
34
|
+
"@shuvi/runtime": "1.0.10",
|
|
35
|
+
"@shuvi/shared": "1.0.10",
|
|
36
|
+
"@shuvi/toolpack": "1.0.10",
|
|
37
|
+
"@shuvi/utils": "1.0.10",
|
|
38
|
+
"@shuvi/error-overlay": "1.0.10",
|
|
39
|
+
"@shuvi/telemetry": "1.0.10",
|
|
40
40
|
"commander": "5.1.0",
|
|
41
41
|
"comment-json": "4.2.2",
|
|
42
42
|
"cross-spawn": "7.0.3",
|