@modern-js/core 2.0.0-beta.1 → 2.0.0-beta.2

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.
Files changed (76) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/dist/bin.js +1 -4
  3. package/dist/config/createLoadedConfig.d.ts +6 -0
  4. package/dist/config/createLoadedConfig.js +35 -0
  5. package/dist/config/createResolvedConfig.d.ts +3 -0
  6. package/dist/config/createResolvedConfig.js +92 -0
  7. package/dist/config/index.d.ts +2 -17
  8. package/dist/config/index.js +2 -136
  9. package/dist/context.d.ts +5 -9
  10. package/dist/index.d.ts +6 -14
  11. package/dist/index.js +23 -62
  12. package/dist/loadPlugins.d.ts +2 -12
  13. package/dist/loadPlugins.js +12 -5
  14. package/dist/manager.d.ts +80 -64
  15. package/dist/manager.js +11 -5
  16. package/dist/schema/patchSchema.d.ts +19 -0
  17. package/dist/{config/schema/index.js → schema/patchSchema.js} +8 -45
  18. package/dist/schema/source.d.ts +9 -0
  19. package/dist/schema/source.js +10 -0
  20. package/dist/schema/testing.d.ts +13 -0
  21. package/dist/schema/testing.js +11 -0
  22. package/dist/schema/traverseSchema.d.ts +2 -0
  23. package/dist/schema/traverseSchema.js +20 -0
  24. package/dist/types/config/index.d.ts +41 -0
  25. package/dist/{config/types → types/config}/index.js +0 -0
  26. package/dist/types/config/testing.d.ts +15 -0
  27. package/dist/{config/types/electron.js → types/config/testing.js} +0 -0
  28. package/dist/types/context.d.ts +26 -0
  29. package/dist/{config/types/less.js → types/context.js} +0 -0
  30. package/dist/types/hooks.d.ts +26 -0
  31. package/dist/{config/types/postcss.js → types/hooks.js} +0 -0
  32. package/dist/types/index.d.ts +10 -1
  33. package/dist/types/index.js +5 -1
  34. package/dist/types/plugin.d.ts +26 -0
  35. package/dist/{config/types/sass.js → types/plugin.js} +0 -0
  36. package/dist/types/pluginAPI.d.ts +18 -0
  37. package/dist/{config/types/ssg.js → types/pluginAPI.js} +0 -0
  38. package/dist/utils/mergeConfig.d.ts +2 -0
  39. package/dist/{config → utils}/mergeConfig.js +1 -8
  40. package/dist/utils/repeatKeyWarning.d.ts +2 -2
  41. package/dist/utils/repeatKeyWarning.js +2 -2
  42. package/package.json +16 -9
  43. package/compiled/v8-compile-cache/index.d.ts +0 -1
  44. package/compiled/v8-compile-cache/index.js +0 -1
  45. package/compiled/v8-compile-cache/license +0 -21
  46. package/compiled/v8-compile-cache/package.json +0 -1
  47. package/dist/config/defaults.d.ts +0 -29
  48. package/dist/config/defaults.js +0 -110
  49. package/dist/config/mergeConfig.d.ts +0 -32
  50. package/dist/config/schema/deploy.d.ts +0 -16
  51. package/dist/config/schema/deploy.js +0 -16
  52. package/dist/config/schema/index.d.ts +0 -499
  53. package/dist/config/schema/output.d.ts +0 -146
  54. package/dist/config/schema/output.js +0 -68
  55. package/dist/config/schema/server.d.ts +0 -194
  56. package/dist/config/schema/server.js +0 -111
  57. package/dist/config/schema/source.d.ts +0 -64
  58. package/dist/config/schema/source.js +0 -38
  59. package/dist/config/schema/tools.d.ts +0 -51
  60. package/dist/config/schema/tools.js +0 -24
  61. package/dist/config/types/electron.d.ts +0 -13
  62. package/dist/config/types/index.d.ts +0 -260
  63. package/dist/config/types/less.d.ts +0 -12
  64. package/dist/config/types/postcss.d.ts +0 -28
  65. package/dist/config/types/sass.d.ts +0 -10
  66. package/dist/config/types/ssg.d.ts +0 -15
  67. package/dist/config/types/test.d.ts +0 -14
  68. package/dist/config/types/test.js +0 -2
  69. package/dist/config/types/ts-loader.d.ts +0 -23
  70. package/dist/config/types/ts-loader.js +0 -2
  71. package/dist/initWatcher.d.ts +0 -3
  72. package/dist/initWatcher.js +0 -66
  73. package/dist/pluginAPI.d.ts +0 -13
  74. package/dist/pluginAPI.js +0 -16
  75. package/dist/types/cli.d.ts +0 -59
  76. package/dist/types/cli.js +0 -2
@@ -1,260 +0,0 @@
1
- import type { DevServerHttpsOptions, DevServerOptions } from '@modern-js/types';
2
- import type { AliasOption, MetaOptions, ChainIdentifier, WatchOptions } from '@modern-js/utils';
3
- import type { BabelConfig } from '@modern-js/babel-preset-app';
4
- import type webpack from 'webpack';
5
- import type { RuleSetRule, Configuration as WebpackConfiguration, WebpackPluginInstance } from 'webpack';
6
- import type WebpackChain from '@modern-js/utils/webpack-chain';
7
- import type autoprefixer from 'autoprefixer';
8
- import type { BasePluginOptions, TerserOptions as RawTerserOptions } from 'terser-webpack-plugin';
9
- import type { AcceptedPlugin as PostCSSPlugin } from 'postcss';
10
- import { TransformOptions } from '@babel/core';
11
- import type { Options as HTMLPluginOptions } from 'html-webpack-plugin';
12
- import type { PluginConfig, NewPluginConfig } from '../../loadPlugins';
13
- import type { TestConfig, JestConfig } from './test';
14
- import type { SassConfig, SassLoaderOptions } from './sass';
15
- import type { LessConfig, LessLoaderOptions } from './less';
16
- import type { SSGConfig, SSGRouteOptions, SSGMultiEntryOptions, SSGSingleEntryOptions } from './ssg';
17
- import type { ElectronConfig } from './electron';
18
- import type { PostCSSLoaderOptions } from './postcss';
19
- import type { TsLoaderOptions } from './ts-loader';
20
- declare type AutoprefixerOptions = autoprefixer.Options;
21
- declare type TerserOptions = BasePluginOptions & {
22
- terserOptions?: Partial<RawTerserOptions>;
23
- };
24
- export type { TestConfig, JestConfig, BabelConfig, SassConfig, SassLoaderOptions, LessConfig, LessLoaderOptions, SSGConfig, SSGRouteOptions, SSGMultiEntryOptions, SSGSingleEntryOptions, TransformOptions, AutoprefixerOptions, TerserOptions, PluginConfig, NewPluginConfig, };
25
- export interface SourceConfig {
26
- entries?: Record<string, string | {
27
- entry: string;
28
- enableFileSystemRoutes?: boolean;
29
- disableMount?: boolean;
30
- }>;
31
- preEntry?: string | string[];
32
- enableAsyncEntry?: boolean;
33
- disableDefaultEntries?: boolean;
34
- entriesDir?: string;
35
- configDir?: string;
36
- apiDir?: string;
37
- envVars?: Array<string>;
38
- globalVars?: Record<string, string>;
39
- alias?: AliasOption;
40
- moduleScopes?: Array<string | RegExp> | ((scopes: Array<string | RegExp>) => void) | ((scopes: Array<string | RegExp>) => Array<string | RegExp>);
41
- include?: Array<string | RegExp>;
42
- /**
43
- * The configuration of `source.designSystem` is provided by `tailwindcss` plugin.
44
- * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
45
- * @requires `tailwindcss` plugin
46
- */
47
- designSystem?: Record<string, any>;
48
- }
49
- export interface OutputConfig {
50
- assetPrefix?: string;
51
- htmlPath?: string;
52
- jsPath?: string;
53
- cssPath?: string;
54
- mediaPath?: string;
55
- path?: string;
56
- title?: string;
57
- titleByEntries?: Record<string, string>;
58
- meta?: MetaOptions;
59
- metaByEntries?: Record<string, MetaOptions>;
60
- inject?: 'body' | 'head' | boolean;
61
- injectByEntries?: Record<string, 'body' | 'head' | boolean>;
62
- mountId?: string;
63
- favicon?: string;
64
- faviconByEntries?: Record<string, string | undefined>;
65
- copy?: Array<Record<string, unknown> & {
66
- from: string;
67
- }>;
68
- scriptExt?: Record<string, unknown>;
69
- disableTsChecker?: boolean;
70
- disableHtmlFolder?: boolean;
71
- disableCssModuleExtension?: boolean;
72
- disableCssExtract?: boolean;
73
- enableCssModuleTSDeclaration?: boolean;
74
- disableMinimize?: boolean;
75
- enableInlineStyles?: boolean;
76
- enableInlineScripts?: boolean;
77
- disableSourceMap?: boolean;
78
- disableInlineRuntimeChunk?: boolean;
79
- disableAssetsCache?: boolean;
80
- enableLatestDecorators?: boolean;
81
- polyfill?: 'off' | 'usage' | 'entry' | 'ua';
82
- dataUriLimit?: number;
83
- templateParameters?: Record<string, unknown>;
84
- templateParametersByEntries?: Record<string, Record<string, unknown> | undefined>;
85
- cssModuleLocalIdentName?: string;
86
- enableModernMode?: boolean;
87
- federation?: boolean;
88
- disableNodePolyfill?: boolean;
89
- enableTsLoader?: boolean;
90
- /**
91
- * The configuration of `output.ssg` is provided by `ssg` plugin.
92
- * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
93
- * @requires `ssg` plugin
94
- */
95
- ssg?: SSGConfig;
96
- }
97
- export interface ServerConfig {
98
- routes?: Record<string, string | string[] | {
99
- route?: string | string[];
100
- disableSpa?: boolean;
101
- resHeaders?: Record<string, unknown>;
102
- }>;
103
- publicRoutes?: {
104
- [filepath: string]: string;
105
- };
106
- ssr?: boolean | {
107
- mode?: 'string' | 'stream';
108
- [property: string]: unknown;
109
- };
110
- ssrByEntries?: Record<string, boolean | {
111
- mode?: 'string' | 'stream';
112
- [property: string]: unknown;
113
- }>;
114
- baseUrl?: string | Array<string>;
115
- port?: number;
116
- logger?: boolean | Record<string, any>;
117
- metrics?: boolean | Record<string, any>;
118
- enableMicroFrontendDebug?: boolean;
119
- watchOptions?: WatchOptions;
120
- compiler?: 'babel' | 'typescript';
121
- disableFrameworkExt?: boolean;
122
- }
123
- export declare type DevProxyOptions = string | Record<string, string>;
124
- export interface DevConfig {
125
- assetPrefix?: string | boolean;
126
- https?: DevServerHttpsOptions;
127
- /**
128
- * The configuration of `dev.proxy` is provided by `proxy` plugin.
129
- * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
130
- * @requires `proxy` plugin
131
- */
132
- proxy?: DevProxyOptions;
133
- }
134
- export interface MicroFrontend {
135
- enableHtmlEntry?: boolean;
136
- externalBasicLibrary?: boolean;
137
- moduleApp?: string;
138
- }
139
- export interface DeployConfig {
140
- microFrontend?: boolean | MicroFrontend;
141
- domain?: string | Array<string>;
142
- domainByEntries?: Record<string, string | Array<string>>;
143
- }
144
- declare type ConfigFunction = Record<string, unknown> | ((config: Record<string, unknown>, utils?: any) => Record<string, unknown> | void);
145
- export declare type PostCSSConfigUtils = {
146
- addPlugins: (plugins: PostCSSPlugin | PostCSSPlugin[]) => void;
147
- };
148
- export declare type PostCSSConfig = PostCSSLoaderOptions | ((options: PostCSSLoaderOptions, utils: PostCSSConfigUtils) => PostCSSLoaderOptions | void);
149
- export declare type WebpackConfigUtils = {
150
- env: string;
151
- /** @deprecated Use target instead */
152
- name: string;
153
- target: string;
154
- webpack: typeof webpack;
155
- HtmlWebpackPlugin: typeof import('html-webpack-plugin');
156
- addRules: (rules: RuleSetRule | RuleSetRule[]) => void;
157
- prependPlugins: (plugins: WebpackPluginInstance | WebpackPluginInstance[]) => void;
158
- appendPlugins: (plugins: WebpackPluginInstance | WebpackPluginInstance[]) => void;
159
- removePlugin: (pluginName: string) => void;
160
- };
161
- export declare type WebpackConfig = WebpackConfiguration | ((config: WebpackConfiguration, utils: WebpackConfigUtils) => WebpackConfiguration | void);
162
- export declare type WebpackChainConfigUtils = {
163
- env: string;
164
- /** @deprecated Use target instead */
165
- name: string;
166
- target: string;
167
- webpack: typeof webpack;
168
- CHAIN_ID: ChainIdentifier;
169
- HtmlWebpackPlugin: typeof import('html-webpack-plugin');
170
- };
171
- export declare type WebpackChainConfig = (chain: WebpackChain, utils: WebpackChainConfigUtils) => void;
172
- export declare type TsLoaderConfigUtils = {
173
- addIncludes: (includes: string | RegExp | (string | RegExp)[]) => void;
174
- addExcludes: (excludes: string | RegExp | (string | RegExp)[]) => void;
175
- };
176
- export declare type TsLoaderConfig = TsLoaderOptions | ((config: TsLoaderOptions, utils: TsLoaderConfigUtils) => TsLoaderOptions | void);
177
- export declare type AutoprefixerConfig = AutoprefixerOptions | ((config: AutoprefixerOptions) => AutoprefixerOptions | void);
178
- export declare type TerserConfig = TerserOptions | ((config: TerserOptions) => TerserOptions | void);
179
- export declare type HtmlPluginConfig = HTMLPluginOptions | ((options: HTMLPluginOptions, entryInfo: {
180
- entryName: string;
181
- entryValue: webpack.Configuration['entry'];
182
- }) => HTMLPluginOptions | void);
183
- export interface ToolsConfig {
184
- webpack?: WebpackConfig;
185
- webpackChain?: WebpackChainConfig;
186
- babel?: BabelConfig;
187
- autoprefixer?: AutoprefixerConfig;
188
- postcss?: PostCSSConfig;
189
- styledComponents?: ConfigFunction;
190
- lodash?: ConfigFunction;
191
- devServer?: DevServerOptions;
192
- tsLoader?: TsLoaderConfig;
193
- terser?: TerserConfig;
194
- minifyCss?: ConfigFunction;
195
- esbuild?: Record<string, unknown>;
196
- htmlPlugin?: HtmlPluginConfig;
197
- /**
198
- * The configuration of `tools.tailwindcss` is provided by `tailwindcss` plugin.
199
- * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
200
- * @requires `tailwindcss` plugin
201
- */
202
- tailwindcss?: Record<string, any> | ((options: Record<string, any>) => Record<string, any> | void);
203
- /**
204
- * The configuration of `tools.jest` is provided by `testing` plugin.
205
- * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
206
- * @requires `testing` plugin
207
- */
208
- jest?: TestConfig['jest'];
209
- sass?: SassConfig;
210
- less?: LessConfig;
211
- }
212
- export interface RuntimeConfig {
213
- [name: string]: any;
214
- }
215
- export interface RuntimeByEntriesConfig {
216
- [name: string]: RuntimeConfig;
217
- }
218
- export interface BffConfig {
219
- prefix?: string;
220
- requestCreator?: string;
221
- fetcher?: string;
222
- proxy?: Record<string, any>;
223
- }
224
- export interface UserConfig {
225
- source?: SourceConfig;
226
- output?: OutputConfig;
227
- server?: ServerConfig;
228
- dev?: DevConfig;
229
- deploy?: DeployConfig;
230
- tools?: ToolsConfig;
231
- plugins?: PluginConfig;
232
- runtime?: RuntimeConfig;
233
- runtimeByEntries?: RuntimeByEntriesConfig;
234
- /**
235
- * The configuration of `bff` is provided by `bff` plugin.
236
- * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
237
- * @requires `bff` plugin
238
- */
239
- bff?: BffConfig;
240
- /**
241
- * The configuration of `testing` is provided by `testing` plugin.
242
- * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
243
- * @requires `testing` plugin
244
- */
245
- testing?: TestConfig;
246
- /**
247
- * The configuration of `electron` is provided by `electron` plugin.
248
- * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
249
- * @requires `electron` plugin
250
- */
251
- electron?: ElectronConfig;
252
- }
253
- export declare type ConfigParam = UserConfig | Promise<UserConfig> | ((env: any) => UserConfig | Promise<UserConfig>);
254
- export interface LoadedConfig {
255
- config: UserConfig;
256
- filePath: string | false;
257
- dependencies: string[];
258
- pkgConfig: UserConfig;
259
- jsConfig: UserConfig;
260
- }
@@ -1,12 +0,0 @@
1
- /// <reference types="less" />
2
- import type { LoaderContext } from 'webpack';
3
- export declare type LessLoaderOptions = {
4
- lessOptions?: Less.Options;
5
- additionalData?: string | ((content: string, loaderContext: LoaderContext<LessLoaderOptions>) => string);
6
- sourceMap?: boolean;
7
- webpackImporter?: boolean;
8
- implementation?: boolean;
9
- };
10
- export declare type LessConfig = LessLoaderOptions | ((options: LessLoaderOptions, utils: {
11
- addExcludes: (excludes: RegExp | RegExp[]) => void;
12
- }) => LessLoaderOptions | void);
@@ -1,28 +0,0 @@
1
- import type { Syntax, Parser, Stringifier, AcceptedPlugin, SourceMapOptions } from 'postcss';
2
- export declare type PostCSSOptions = {
3
- to?: string;
4
- from?: string;
5
- map?: boolean | SourceMapOptions;
6
- syntax?: Syntax;
7
- parser?: string | object | (() => Parser);
8
- plugins?: AcceptedPlugin[];
9
- stringifier?: Stringifier | Syntax;
10
- };
11
- export declare type PostCSSLoaderOptions = {
12
- /**
13
- * Enable PostCSS Parser support in CSS-in-JS. If you use JS styles the postcss-js parser, add the execute option.
14
- */
15
- execute?: boolean;
16
- /**
17
- * By default generation of source maps depends on the devtool option. All values enable source map generation except eval and false value.
18
- */
19
- sourceMap?: boolean;
20
- /**
21
- * The special implementation option determines which implementation of PostCSS to use.
22
- */
23
- implementation?: unknown;
24
- /**
25
- * Allows to set PostCSS options and plugins.
26
- */
27
- postcssOptions?: PostCSSOptions;
28
- };
@@ -1,10 +0,0 @@
1
- import type { LegacyFileOptions } from 'sass';
2
- export interface SassLoaderOptions {
3
- sassOptions?: LegacyFileOptions<'sync'>;
4
- sourceMap?: boolean;
5
- implementation?: string;
6
- additionalData?: string | ((content: string, filename: string) => string);
7
- }
8
- export declare type SassConfig = SassLoaderOptions | ((options: SassLoaderOptions, utils: {
9
- addExcludes: (excludes: RegExp | RegExp[]) => void;
10
- }) => SassLoaderOptions | void);
@@ -1,15 +0,0 @@
1
- export declare type SSGRouteOptions = string | {
2
- url: string;
3
- output?: string;
4
- params?: Record<string, any>[];
5
- headers?: Record<string, any>;
6
- };
7
- export declare type SSGSingleEntryOptions = boolean | {
8
- preventDefault?: string[];
9
- headers?: Record<string, any>;
10
- routes?: SSGRouteOptions[];
11
- };
12
- export declare type SSGMultiEntryOptions = Record<string, SSGSingleEntryOptions>;
13
- export declare type SSGConfig = boolean | SSGSingleEntryOptions | SSGMultiEntryOptions | ((entryName: string, payload: {
14
- baseUrl?: string;
15
- }) => SSGSingleEntryOptions);
@@ -1,14 +0,0 @@
1
- import type { Config as JestConfigTypes } from '@jest/types';
2
- export declare type JestConfig = JestConfigTypes.InitialOptions;
3
- export interface TestConfig {
4
- /**
5
- * Decide which transformer will be used to compile file
6
- * Default: babel-jest
7
- */
8
- transformer?: 'babel-jest' | 'ts-jest';
9
- /**
10
- * Original jest config
11
- * Doc: https://jestjs.io/docs/configuration
12
- */
13
- jest?: JestConfig | ((jestConfig: JestConfig) => JestConfig);
14
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,23 +0,0 @@
1
- export declare type TsLoaderOptions = {
2
- colors?: boolean;
3
- silent?: boolean;
4
- context?: string;
5
- instance?: string;
6
- logLevel?: string;
7
- compiler?: string;
8
- configFile?: string;
9
- reportFiles?: string[];
10
- transpileOnly?: boolean;
11
- happyPackMode?: boolean;
12
- errorFormatter?: (message: Record<string, unknown>, colors: boolean) => string;
13
- logInfoToStdOut?: boolean;
14
- compilerOptions?: Record<string, unknown>;
15
- appendTsSuffixTo?: (RegExp | string)[];
16
- appendTsxSuffixTo?: (RegExp | string)[];
17
- projectReferences?: boolean;
18
- ignoreDiagnostics?: number[];
19
- allowTsInNodeModules?: boolean;
20
- experimentalFileCaching?: boolean;
21
- onlyCompileBundledFiles?: boolean;
22
- useCaseSensitiveFileNames?: boolean;
23
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +0,0 @@
1
- import { LoadedConfig } from './config';
2
- import { HooksRunner } from './manager';
3
- export declare const initWatcher: (loaded: LoadedConfig, appDirectory: string, configDir: string | undefined, hooksRunner: HooksRunner, argv: string[]) => Promise<import("@modern-js/utils").FSWatcher | undefined>;
@@ -1,66 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.initWatcher = void 0;
7
- const crypto_1 = __importDefault(require("crypto"));
8
- const fs_1 = __importDefault(require("fs"));
9
- const path_1 = __importDefault(require("path"));
10
- const utils_1 = require("@modern-js/utils");
11
- const debug = (0, utils_1.createDebugger)('watch-files');
12
- const md5 = (data) => crypto_1.default.createHash('md5').update(data).digest('hex');
13
- const hashMap = new Map();
14
- const initWatcher = async (loaded, appDirectory, configDir, hooksRunner, argv) => {
15
- // only add fs watcher on dev mode.
16
- if (((0, utils_1.isDev)() || (0, utils_1.isTest)()) && argv[0] === 'dev') {
17
- const extraFiles = await hooksRunner.watchFiles();
18
- const configPath = path_1.default.join(appDirectory, configDir);
19
- const watched = [
20
- `${configPath}/html`,
21
- ...extraFiles,
22
- loaded === null || loaded === void 0 ? void 0 : loaded.filePath,
23
- ...loaded.dependencies,
24
- ].filter(Boolean);
25
- debug(`watched: %o`, watched);
26
- const watcher = utils_1.chokidar.watch(watched, {
27
- cwd: appDirectory,
28
- ignoreInitial: true,
29
- ignorePermissionErrors: true,
30
- ignored: [
31
- /node_modules/,
32
- '**/__test__/**',
33
- '**/*.test.(js|jsx|ts|tsx)',
34
- '**/*.spec.(js|jsx|ts|tsx)',
35
- '**/*.stories.(js|jsx|ts|tsx)',
36
- ],
37
- });
38
- watcher.on('change', changed => {
39
- const lastHash = hashMap.get(changed);
40
- const currentHash = md5(fs_1.default.readFileSync(path_1.default.join(appDirectory, changed), 'utf8'));
41
- if (currentHash !== lastHash) {
42
- debug(`file change: %s`, changed);
43
- hashMap.set(changed, currentHash);
44
- hooksRunner.fileChange({ filename: changed, eventType: 'change' });
45
- }
46
- });
47
- watcher.on('add', name => {
48
- debug(`add file: %s`, name);
49
- const currentHash = md5(fs_1.default.readFileSync(path_1.default.join(appDirectory, name), 'utf8'));
50
- hashMap.set(name, currentHash);
51
- hooksRunner.fileChange({ filename: name, eventType: 'add' });
52
- });
53
- watcher.on('unlink', name => {
54
- debug(`remove file: %s`, name);
55
- if (hashMap.has(name)) {
56
- hashMap.delete(name);
57
- }
58
- hooksRunner.fileChange({ filename: name, eventType: 'unlink' });
59
- });
60
- watcher.on('error', err => {
61
- throw err;
62
- });
63
- return watcher;
64
- }
65
- };
66
- exports.initWatcher = initWatcher;
@@ -1,13 +0,0 @@
1
- import type { CommonAPI } from '@modern-js/plugin';
2
- import type { CliHooks } from './manager';
3
- import { AppContext, ConfigContext, useAppContext, useConfigContext, ResolvedConfigContext, useResolvedConfigContext } from './context';
4
- export declare const pluginAPI: {
5
- setAppContext: (value: import("@modern-js/types").IAppContext) => void;
6
- useAppContext: () => import("@modern-js/types").IAppContext;
7
- useConfigContext: () => import("./config").UserConfig;
8
- useResolvedConfigContext: () => import("./config").NormalizedConfig;
9
- };
10
- export type { IAppContext } from '@modern-js/types';
11
- /** all apis for cli plugin */
12
- export declare type PluginAPI<ExtendHooks = Record<string, any>> = typeof pluginAPI & CommonAPI<CliHooks & ExtendHooks>;
13
- export { AppContext, ConfigContext, ResolvedConfigContext, useAppContext, useConfigContext, useResolvedConfigContext, };
package/dist/pluginAPI.js DELETED
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useResolvedConfigContext = exports.useConfigContext = exports.useAppContext = exports.ResolvedConfigContext = exports.ConfigContext = exports.AppContext = exports.pluginAPI = void 0;
4
- const context_1 = require("./context");
5
- Object.defineProperty(exports, "AppContext", { enumerable: true, get: function () { return context_1.AppContext; } });
6
- Object.defineProperty(exports, "ConfigContext", { enumerable: true, get: function () { return context_1.ConfigContext; } });
7
- Object.defineProperty(exports, "useAppContext", { enumerable: true, get: function () { return context_1.useAppContext; } });
8
- Object.defineProperty(exports, "useConfigContext", { enumerable: true, get: function () { return context_1.useConfigContext; } });
9
- Object.defineProperty(exports, "ResolvedConfigContext", { enumerable: true, get: function () { return context_1.ResolvedConfigContext; } });
10
- Object.defineProperty(exports, "useResolvedConfigContext", { enumerable: true, get: function () { return context_1.useResolvedConfigContext; } });
11
- exports.pluginAPI = {
12
- setAppContext: context_1.setAppContext,
13
- useAppContext: context_1.useAppContext,
14
- useConfigContext: context_1.useConfigContext,
15
- useResolvedConfigContext: context_1.useResolvedConfigContext,
16
- };
@@ -1,59 +0,0 @@
1
- import { AsyncWaterfall, AsyncWorkflow } from '@modern-js/plugin';
2
- import { Entrypoint, HtmlPartials, NestedRoute, PageRoute, RouteLegacy, ServerRoute } from '@modern-js/types';
3
- export interface ImportSpecifier {
4
- local?: string;
5
- imported?: string;
6
- }
7
- export interface ImportStatement {
8
- specifiers: ImportSpecifier[];
9
- value: string;
10
- initialize?: string;
11
- }
12
- export interface RuntimePlugin {
13
- name: string;
14
- options: string;
15
- args?: string;
16
- }
17
- export interface Hooks {
18
- afterMonorepoDeploy: AsyncWorkflow<{
19
- operator: any;
20
- deployProjectNames: string[];
21
- }, void>;
22
- modifyEntryExport: AsyncWaterfall<{
23
- entrypoint: Entrypoint;
24
- exportStatement: string;
25
- }>;
26
- modifyEntryImports: AsyncWaterfall<{
27
- imports: ImportStatement[];
28
- entrypoint: Entrypoint;
29
- }>;
30
- modifyEntryRuntimePlugins: AsyncWaterfall<{
31
- entrypoint: Entrypoint;
32
- plugins: RuntimePlugin[];
33
- }>;
34
- modifyEntryRenderFunction: AsyncWaterfall<{
35
- entrypoint: Entrypoint;
36
- code: string;
37
- }>;
38
- modifyAsyncEntry: AsyncWaterfall<{
39
- entrypoint: Entrypoint;
40
- code: string;
41
- }>;
42
- modifyFileSystemRoutes: AsyncWaterfall<{
43
- entrypoint: Entrypoint;
44
- routes: RouteLegacy[] | (NestedRoute | PageRoute)[];
45
- }>;
46
- modifyServerRoutes: AsyncWaterfall<{
47
- routes: ServerRoute[];
48
- }>;
49
- htmlPartials: AsyncWaterfall<{
50
- entrypoint: Entrypoint;
51
- partials: HtmlPartials;
52
- }>;
53
- addRuntimeExports: AsyncWaterfall<void>;
54
- beforeGenerateRoutes: AsyncWaterfall<{
55
- entrypoint: Entrypoint;
56
- code: string;
57
- }>;
58
- addDefineTypes: AsyncWaterfall<void>;
59
- }
package/dist/types/cli.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });