@modern-js/plugin-swc 2.0.0-beta.2 → 2.0.0-beta.4
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 +72 -0
- package/package.json +10 -10
- package/dist/bin.d.ts +0 -2
- package/dist/bin.js +0 -38
- package/dist/config/createLoadedConfig.d.ts +0 -6
- package/dist/config/createLoadedConfig.js +0 -35
- package/dist/config/createResolvedConfig.d.ts +0 -3
- package/dist/config/createResolvedConfig.js +0 -91
- package/dist/config/defaults.d.ts +0 -29
- package/dist/config/defaults.js +0 -110
- package/dist/config/index.d.ts +0 -2
- package/dist/config/index.js +0 -18
- package/dist/config/mergeConfig.d.ts +0 -32
- package/dist/config/mergeConfig.js +0 -39
- package/dist/config/schema/deploy.d.ts +0 -16
- package/dist/config/schema/deploy.js +0 -16
- package/dist/config/schema/index.d.ts +0 -499
- package/dist/config/schema/index.js +0 -94
- package/dist/config/schema/output.d.ts +0 -146
- package/dist/config/schema/output.js +0 -68
- package/dist/config/schema/server.d.ts +0 -194
- package/dist/config/schema/server.js +0 -111
- package/dist/config/schema/source.d.ts +0 -64
- package/dist/config/schema/source.js +0 -38
- package/dist/config/schema/tools.d.ts +0 -51
- package/dist/config/schema/tools.js +0 -24
- package/dist/config/types/electron.d.ts +0 -13
- package/dist/config/types/electron.js +0 -2
- package/dist/config/types/index.d.ts +0 -260
- package/dist/config/types/index.js +0 -2
- package/dist/config/types/less.d.ts +0 -12
- package/dist/config/types/less.js +0 -2
- package/dist/config/types/postcss.d.ts +0 -28
- package/dist/config/types/postcss.js +0 -2
- package/dist/config/types/sass.d.ts +0 -10
- package/dist/config/types/sass.js +0 -2
- package/dist/config/types/ssg.d.ts +0 -15
- package/dist/config/types/ssg.js +0 -2
- package/dist/config/types/test.d.ts +0 -14
- package/dist/config/types/test.js +0 -2
- package/dist/config/types/ts-loader.d.ts +0 -23
- package/dist/config/types/ts-loader.js +0 -2
- package/dist/context.d.ts +0 -34
- package/dist/context.js +0 -60
- package/dist/initWatcher.d.ts +0 -3
- package/dist/initWatcher.js +0 -66
- package/dist/load-configs/index.d.ts +0 -34
- package/dist/load-configs/index.js +0 -124
- package/dist/loadEnv.d.ts +0 -1
- package/dist/loadEnv.js +0 -21
- package/dist/loadPlugins.d.ts +0 -16
- package/dist/loadPlugins.js +0 -60
- package/dist/manager.d.ts +0 -87
- package/dist/manager.js +0 -24
- package/dist/pluginAPI.d.ts +0 -13
- package/dist/pluginAPI.js +0 -16
- package/dist/schema/patchSchema.d.ts +0 -19
- package/dist/schema/patchSchema.js +0 -57
- package/dist/schema/source.d.ts +0 -9
- package/dist/schema/source.js +0 -10
- package/dist/schema/testing.d.ts +0 -13
- package/dist/schema/testing.js +0 -11
- package/dist/schema/traverseSchema.d.ts +0 -2
- package/dist/schema/traverseSchema.js +0 -20
- package/dist/types/cli.d.ts +0 -59
- package/dist/types/cli.js +0 -2
- package/dist/types/config/index.d.ts +0 -41
- package/dist/types/config/index.js +0 -2
- package/dist/types/config/testing.d.ts +0 -15
- package/dist/types/config/testing.js +0 -2
- package/dist/types/context.d.ts +0 -26
- package/dist/types/context.js +0 -2
- package/dist/types/hooks.d.ts +0 -26
- package/dist/types/hooks.js +0 -2
- package/dist/types/index.d.ts +0 -10
- package/dist/types/index.js +0 -21
- package/dist/types/plugin.d.ts +0 -26
- package/dist/types/plugin.js +0 -2
- package/dist/types/pluginAPI.d.ts +0 -18
- package/dist/types/pluginAPI.js +0 -2
- package/dist/utils/commander.d.ts +0 -4
- package/dist/utils/commander.js +0 -20
- package/dist/utils/mergeConfig.d.ts +0 -2
- package/dist/utils/mergeConfig.js +0 -32
- package/dist/utils/repeatKeyWarning.d.ts +0 -3
- package/dist/utils/repeatKeyWarning.js +0 -22
package/dist/types/context.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Entrypoint, InternalPlugins, ServerRoute, HtmlTemplates } from '@modern-js/types';
|
|
2
|
-
import { BuilderInstance } from '@modern-js/builder-shared';
|
|
3
|
-
export interface IAppContext {
|
|
4
|
-
metaName: string;
|
|
5
|
-
appDirectory: string;
|
|
6
|
-
configFile: string | false;
|
|
7
|
-
serverConfigFile: string;
|
|
8
|
-
serverInternalPlugins: InternalPlugins;
|
|
9
|
-
ip?: string;
|
|
10
|
-
port?: number;
|
|
11
|
-
distDirectory: string;
|
|
12
|
-
packageName: string;
|
|
13
|
-
srcDirectory: string;
|
|
14
|
-
sharedDirectory: string;
|
|
15
|
-
nodeModulesDirectory: string;
|
|
16
|
-
internalDirectory: string;
|
|
17
|
-
plugins: any[];
|
|
18
|
-
entrypoints: Entrypoint[];
|
|
19
|
-
checkedEntries: string[];
|
|
20
|
-
serverRoutes: ServerRoute[];
|
|
21
|
-
htmlTemplates: HtmlTemplates;
|
|
22
|
-
apiOnly: boolean;
|
|
23
|
-
internalDirAlias: string;
|
|
24
|
-
internalSrcAlias: string;
|
|
25
|
-
builder?: BuilderInstance;
|
|
26
|
-
}
|
package/dist/types/context.js
DELETED
package/dist/types/hooks.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ParallelWorkflow, AsyncWaterfall, AsyncWorkflow, ToRunners, ToThreads } from '@modern-js/plugin';
|
|
2
|
-
import type { Command } from '@modern-js/utils';
|
|
3
|
-
import type { UserConfig, NormalizedConfig } from './config';
|
|
4
|
-
export declare type BaseHooks<Extends extends {
|
|
5
|
-
hooks?: ExtendHooks;
|
|
6
|
-
userConfig?: ExtendUserConfig;
|
|
7
|
-
normalizedConfig?: ExtendNormalizedConfig;
|
|
8
|
-
}, ExtendHooks extends {} = {}, ExtendUserConfig extends Record<string, any> = {}, ExtendNormalizedConfig extends Record<string, any> = {}> = {
|
|
9
|
-
config: ParallelWorkflow<void, UserConfig<Extends>>;
|
|
10
|
-
resolvedConfig: AsyncWaterfall<{
|
|
11
|
-
resolved: NormalizedConfig<Extends>;
|
|
12
|
-
}>;
|
|
13
|
-
validateSchema: ParallelWorkflow<void>;
|
|
14
|
-
prepare: AsyncWorkflow<void, void>;
|
|
15
|
-
commands: AsyncWorkflow<{
|
|
16
|
-
program: Command;
|
|
17
|
-
}, void>;
|
|
18
|
-
beforeExit: AsyncWorkflow<void, void>;
|
|
19
|
-
addRuntimeExports: AsyncWaterfall<void>;
|
|
20
|
-
};
|
|
21
|
-
export declare type CliHooksRunner<Extends extends {
|
|
22
|
-
hooks?: ExtendHooks;
|
|
23
|
-
userConfig?: ExtendUserConfig;
|
|
24
|
-
normalizedConfig?: ExtendNormalizedConfig;
|
|
25
|
-
} = {}, ExtendHooks extends {} = {}, ExtendUserConfig extends Record<string, any> = {}, ExtendNormalizedConfig extends Record<string, any> = {}> = ToRunners<BaseHooks<Extends> & Extends['hooks']>;
|
|
26
|
-
export declare type CliHookCallbacks = ToThreads<BaseHooks<{}>>;
|
package/dist/types/hooks.js
DELETED
package/dist/types/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { JSONSchemaType } from '@modern-js/utils/ajv/json-schema';
|
|
2
|
-
export * from './plugin';
|
|
3
|
-
export * from './config';
|
|
4
|
-
export * from './pluginAPI';
|
|
5
|
-
export * from './hooks';
|
|
6
|
-
export * from './context';
|
|
7
|
-
export interface PluginValidateSchema {
|
|
8
|
-
target: string;
|
|
9
|
-
schema: JSONSchemaType<any>;
|
|
10
|
-
}
|
package/dist/types/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./plugin"), exports);
|
|
18
|
-
__exportStar(require("./config"), exports);
|
|
19
|
-
__exportStar(require("./pluginAPI"), exports);
|
|
20
|
-
__exportStar(require("./hooks"), exports);
|
|
21
|
-
__exportStar(require("./context"), exports);
|
package/dist/types/plugin.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { AsyncSetup, PluginOptions } from '@modern-js/plugin';
|
|
2
|
-
import { BaseHooks } from './hooks';
|
|
3
|
-
import { BasePluginAPI } from './pluginAPI';
|
|
4
|
-
export type { InternalPlugins } from '@modern-js/types';
|
|
5
|
-
/** Plugin options of a cli plugin. */
|
|
6
|
-
export declare type CliPlugin<Extends extends {
|
|
7
|
-
hooks?: ExtendHooks;
|
|
8
|
-
userConfig?: ExtendUserConfig;
|
|
9
|
-
normalizedConfig?: ExtendNormalizedConfig;
|
|
10
|
-
} = {}, ExtendHooks extends Record<string, any> = {}, ExtendUserConfig extends Record<string, any> = {}, ExtendNormalizedConfig extends Record<string, any> = {}> = PluginOptions<BaseHooks<Extends>, AsyncSetup<BaseHooks<Extends> & Extends['hooks'], BasePluginAPI<Extends>>, Extends['hooks'], BaseHooks<Extends> | BaseHooks<{}>, AsyncSetup<BaseHooks<Extends> & Extends['hooks'], BasePluginAPI<Extends>> | AsyncSetup<BaseHooks<{}>, BasePluginAPI<{}>>>;
|
|
11
|
-
export declare type PluginItem = string | [string, any];
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated
|
|
14
|
-
* Using NewPluginConfig instead.
|
|
15
|
-
*/
|
|
16
|
-
export declare type OldPluginConfig = Array<PluginItem>;
|
|
17
|
-
export declare type NewPluginConfig<PluginTypes extends {
|
|
18
|
-
hooks?: Record<string, any>;
|
|
19
|
-
userConfig?: Record<string, any>;
|
|
20
|
-
normalizedConfig?: Record<string, any>;
|
|
21
|
-
}> = CliPlugin<PluginTypes>[];
|
|
22
|
-
export declare type PluginConfig<PluginTypes extends {
|
|
23
|
-
hooks?: Record<string, any>;
|
|
24
|
-
userConfig?: Record<string, any>;
|
|
25
|
-
normalizedConfig?: Record<string, any>;
|
|
26
|
-
} = {}> = OldPluginConfig | NewPluginConfig<PluginTypes>;
|
package/dist/types/plugin.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { CommonAPI } from '@modern-js/plugin';
|
|
2
|
-
import type { setAppContext, useAppContext, useResolvedConfigContext, useConfigContext } from '../context';
|
|
3
|
-
import { BaseHooks } from './hooks';
|
|
4
|
-
export declare type BasePluginAPI<Extends extends {
|
|
5
|
-
hooks?: ExtendHooks;
|
|
6
|
-
userConfig?: ExtendUserConfig;
|
|
7
|
-
normalizedConfig?: ExtendNormalizedConfig;
|
|
8
|
-
}, ExtendHooks extends {} = {}, ExtendUserConfig extends Record<string, any> = {}, ExtendNormalizedConfig extends Record<string, any> = {}> = {
|
|
9
|
-
setAppContext: typeof setAppContext;
|
|
10
|
-
useAppContext: typeof useAppContext;
|
|
11
|
-
useConfigContext: typeof useConfigContext<Extends>;
|
|
12
|
-
useResolvedConfigContext: typeof useResolvedConfigContext<Extends>;
|
|
13
|
-
};
|
|
14
|
-
/** all apis for cli plugin */
|
|
15
|
-
export declare type PluginAPI<Extends extends {
|
|
16
|
-
hooks?: ExtendHooks;
|
|
17
|
-
userConfig?: ExtendUserConfig;
|
|
18
|
-
} = {}, ExtendHooks extends {} = {}, ExtendUserConfig extends Record<string, any> = {}> = BasePluginAPI<Extends> & CommonAPI<BaseHooks<Extends> & Extends['hooks']>;
|
package/dist/types/pluginAPI.js
DELETED
package/dist/utils/commander.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.program = exports.initCommandsMap = void 0;
|
|
4
|
-
const utils_1 = require("@modern-js/utils");
|
|
5
|
-
Object.defineProperty(exports, "program", { enumerable: true, get: function () { return utils_1.program; } });
|
|
6
|
-
function initCommandsMap() {
|
|
7
|
-
if (!utils_1.program.hasOwnProperty('commandsMap')) {
|
|
8
|
-
Object.defineProperty(utils_1.program, 'commandsMap', {
|
|
9
|
-
get() {
|
|
10
|
-
const map = new Map();
|
|
11
|
-
for (const command of utils_1.program.commands) {
|
|
12
|
-
map.set(command._name, command);
|
|
13
|
-
}
|
|
14
|
-
return map;
|
|
15
|
-
},
|
|
16
|
-
configurable: false,
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.initCommandsMap = initCommandsMap;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { UserConfig, NormalizedConfig } from '../types';
|
|
2
|
-
export declare const mergeConfig: <ExtendConfig extends Record<string, any>>(configs: (UserConfig<ExtendConfig, {}, {}, {}> | NormalizedConfig<ExtendConfig, {}, {}, {}>)[]) => NormalizedConfig<ExtendConfig, {}, {}, {}>;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mergeConfig = void 0;
|
|
4
|
-
const lodash_1 = require("@modern-js/utils/lodash");
|
|
5
|
-
const mergeConfig = (configs) => (0, lodash_1.mergeWith)({}, ...configs, (target, source, key) => {
|
|
6
|
-
// Do not use the following merge logic for source.designSystem and tools.tailwind(css)
|
|
7
|
-
if (key === 'designSystem' ||
|
|
8
|
-
(key === 'tailwind' && typeof source === 'object') ||
|
|
9
|
-
(key === 'tailwindcss' && typeof source === 'object') ||
|
|
10
|
-
key === 'devServer') {
|
|
11
|
-
return (0, lodash_1.mergeWith)({}, target !== null && target !== void 0 ? target : {}, source !== null && source !== void 0 ? source : {});
|
|
12
|
-
}
|
|
13
|
-
if (Array.isArray(target)) {
|
|
14
|
-
if (Array.isArray(source)) {
|
|
15
|
-
return [...target, ...source];
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
return source !== undefined ? [...target, source] : target;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
else if ((0, lodash_1.isFunction)(target) || (0, lodash_1.isFunction)(source)) {
|
|
22
|
-
if (source === undefined) {
|
|
23
|
-
return target;
|
|
24
|
-
}
|
|
25
|
-
if (target === undefined) {
|
|
26
|
-
return source;
|
|
27
|
-
}
|
|
28
|
-
return [target, source];
|
|
29
|
-
}
|
|
30
|
-
return undefined;
|
|
31
|
-
});
|
|
32
|
-
exports.mergeConfig = mergeConfig;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.repeatKeyWarning = exports.deepGet = void 0;
|
|
4
|
-
const traverseSchema_1 = require("../schema/traverseSchema");
|
|
5
|
-
const deepGet = (obj, key) => {
|
|
6
|
-
for (const p of key.split('.')) {
|
|
7
|
-
// eslint-disable-next-line no-param-reassign
|
|
8
|
-
obj = obj ? obj[p] : undefined;
|
|
9
|
-
}
|
|
10
|
-
return obj;
|
|
11
|
-
};
|
|
12
|
-
exports.deepGet = deepGet;
|
|
13
|
-
const repeatKeyWarning = (schema, jsConfig, pkgConfig) => {
|
|
14
|
-
const keys = (0, traverseSchema_1.traverseSchema)(schema);
|
|
15
|
-
for (const key of keys) {
|
|
16
|
-
if ((0, exports.deepGet)(jsConfig, key) !== undefined &&
|
|
17
|
-
(0, exports.deepGet)(pkgConfig, key) !== undefined) {
|
|
18
|
-
throw new Error(`The same configuration ${key} exists in modern.config.js and package.json.\n Please remove it from package.json.`);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
exports.repeatKeyWarning = repeatKeyWarning;
|