ko 6.5.12 → 6.6.0-beta.1
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/actions/build.d.ts +12 -0
- package/lib/actions/dev.d.ts +15 -0
- package/lib/actions/dev.js +5 -1
- package/lib/actions/factory.d.ts +12 -0
- package/lib/actions/lints.d.ts +11 -0
- package/lib/cli.d.ts +2 -0
- package/lib/cli.js +0 -0
- package/lib/core/commander.d.ts +29 -0
- package/lib/core/config.d.ts +15 -0
- package/lib/core/hooks.d.ts +12 -0
- package/lib/core/service.d.ts +12 -0
- package/lib/types.d.ts +139 -0
- package/lib/utils/index.d.ts +3 -0
- package/lib/webpack/custom-plugins/purge-cache-webpack-plugin/index.d.ts +7 -0
- package/lib/webpack/custom-plugins/purge-cache-webpack-plugin/index.js +70 -0
- package/lib/webpack/index.d.ts +14 -0
- package/lib/webpack/index.js +1 -0
- package/lib/webpack/loaders/asset.d.ts +8 -0
- package/lib/webpack/loaders/babel/index.d.ts +50 -0
- package/lib/webpack/loaders/index.d.ts +71 -0
- package/lib/webpack/loaders/script.d.ts +61 -0
- package/lib/webpack/loaders/style.d.ts +72 -0
- package/lib/webpack/plugins.d.ts +3 -0
- package/lib/webpack/plugins.js +2 -2
- package/package.json +14 -15
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import webpack from 'webpack';
|
|
2
|
+
import Service from '../core/service';
|
|
3
|
+
import { ActionFactory } from './factory';
|
|
4
|
+
import { ICliOptions } from '../types';
|
|
5
|
+
declare class Build extends ActionFactory {
|
|
6
|
+
private webpackConfig;
|
|
7
|
+
constructor(service: Service);
|
|
8
|
+
protected generateConfig(): Promise<webpack.Configuration>;
|
|
9
|
+
registerCommand(): void;
|
|
10
|
+
protected action(cliOpts: ICliOptions): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export default Build;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Webpack from 'webpack';
|
|
2
|
+
import Service from '../core/service';
|
|
3
|
+
import ActionFactory from './factory';
|
|
4
|
+
import { ICliOptions } from '../types';
|
|
5
|
+
declare class Dev extends ActionFactory {
|
|
6
|
+
private webpackConfig;
|
|
7
|
+
constructor(service: Service);
|
|
8
|
+
private get devServerConfig();
|
|
9
|
+
protected generateConfig(): Promise<Webpack.Configuration>;
|
|
10
|
+
registerCommand(): void;
|
|
11
|
+
private changePort;
|
|
12
|
+
private checkPort;
|
|
13
|
+
protected action(cliOpts: ICliOptions): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export default Dev;
|
package/lib/actions/dev.js
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Service from '../core/service';
|
|
2
|
+
export declare abstract class ActionFactory {
|
|
3
|
+
protected service: Service;
|
|
4
|
+
protected abstract generateConfig(opts: any): any;
|
|
5
|
+
protected abstract registerCommand(): void;
|
|
6
|
+
protected abstract action(...args: any[]): void;
|
|
7
|
+
protected constructor(service: Service);
|
|
8
|
+
protected successStdout(...logs: string[]): void;
|
|
9
|
+
protected warningStdout(...logs: string[]): void;
|
|
10
|
+
protected errorStdout(...logs: string[]): void;
|
|
11
|
+
}
|
|
12
|
+
export default ActionFactory;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ActionFactory } from './factory';
|
|
2
|
+
import { IKeys, IOpts as ILintOpts } from 'ko-lints';
|
|
3
|
+
import Service from '../core/service';
|
|
4
|
+
declare class LintFactory extends ActionFactory {
|
|
5
|
+
private name;
|
|
6
|
+
constructor(service: Service, name: IKeys);
|
|
7
|
+
generateConfig(): {};
|
|
8
|
+
registerCommand(): void;
|
|
9
|
+
protected action(patterns: string | string[], cliOpts: ILintOpts): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export default LintFactory;
|
package/lib/cli.d.ts
ADDED
package/lib/cli.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { program, Command } from 'commander';
|
|
2
|
+
type RegisterOptions = {
|
|
3
|
+
flags: string;
|
|
4
|
+
description: string;
|
|
5
|
+
defaultValue?: string | boolean;
|
|
6
|
+
};
|
|
7
|
+
type CMDProperties = {
|
|
8
|
+
description: string;
|
|
9
|
+
options?: RegisterOptions[];
|
|
10
|
+
args?: {
|
|
11
|
+
flags: string;
|
|
12
|
+
description: string;
|
|
13
|
+
}[];
|
|
14
|
+
action?: ActionFn;
|
|
15
|
+
};
|
|
16
|
+
type ActionFn = Parameters<typeof program.action>[0];
|
|
17
|
+
declare class Commander {
|
|
18
|
+
private STATE;
|
|
19
|
+
program: Command;
|
|
20
|
+
private pkg;
|
|
21
|
+
private cmdSet;
|
|
22
|
+
constructor();
|
|
23
|
+
registerCommand({ name, description, args, options, }: CMDProperties & {
|
|
24
|
+
name: string;
|
|
25
|
+
}): void;
|
|
26
|
+
bindAction(name: string, fn: ActionFn): void;
|
|
27
|
+
parse(): void;
|
|
28
|
+
}
|
|
29
|
+
export default Commander;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IOptions, ICliOptions } from '../types';
|
|
2
|
+
declare class Config {
|
|
3
|
+
private cwd;
|
|
4
|
+
private origin;
|
|
5
|
+
private current;
|
|
6
|
+
private path;
|
|
7
|
+
cliOpts: Partial<ICliOptions>;
|
|
8
|
+
constructor();
|
|
9
|
+
private get isDevOrBuildCommand();
|
|
10
|
+
private getConfigPath;
|
|
11
|
+
generate(): IOptions;
|
|
12
|
+
freezeWithOpts(cliOpts: Partial<ICliOptions>): Readonly<Record<string, any> & Partial<ICliOptions>>;
|
|
13
|
+
get default(): Partial<IOptions>;
|
|
14
|
+
}
|
|
15
|
+
export default Config;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HOOK_KEY_SET, HookOptions } from '../types';
|
|
2
|
+
declare class Hooks {
|
|
3
|
+
private hooks;
|
|
4
|
+
hookKeySet: typeof HOOK_KEY_SET;
|
|
5
|
+
constructor();
|
|
6
|
+
register({ key, action, opts }: HookOptions): void;
|
|
7
|
+
apply(opts: {
|
|
8
|
+
key: string;
|
|
9
|
+
context?: any;
|
|
10
|
+
}): Promise<any>;
|
|
11
|
+
}
|
|
12
|
+
export default Hooks;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Commander from './commander';
|
|
2
|
+
import Hooks from './hooks';
|
|
3
|
+
import { IOptions, ICliOptions } from '../types';
|
|
4
|
+
declare class Service extends Hooks {
|
|
5
|
+
config: IOptions;
|
|
6
|
+
cliOpts: Partial<ICliOptions>;
|
|
7
|
+
commander: Commander;
|
|
8
|
+
constructor();
|
|
9
|
+
freezeCliOptsWith(cliOpts: Partial<ICliOptions>): void;
|
|
10
|
+
run(): void;
|
|
11
|
+
}
|
|
12
|
+
export default Service;
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Pattern } from 'copy-webpack-plugin';
|
|
2
|
+
import { Plugin } from 'postcss';
|
|
3
|
+
import { IKeys, IOpts } from 'ko-lints';
|
|
4
|
+
import { IOpts as AutoPolyfillsWebpackPluginOptions } from '@dtinsight/auto-polyfills-webpack-plugin';
|
|
5
|
+
export type IOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* The current working directory.
|
|
8
|
+
* @param {string}
|
|
9
|
+
*/
|
|
10
|
+
cwd: string;
|
|
11
|
+
/**
|
|
12
|
+
* An object mapping module names to file paths or directories.
|
|
13
|
+
* @param {Record<string, string>}
|
|
14
|
+
*/
|
|
15
|
+
alias?: Record<string, string>;
|
|
16
|
+
/**
|
|
17
|
+
* An array of patterns specifying files to copy to the output directory.
|
|
18
|
+
* @param {Pattern[]}
|
|
19
|
+
*/
|
|
20
|
+
copy?: Pattern[];
|
|
21
|
+
/**
|
|
22
|
+
* The entry point of the application.
|
|
23
|
+
* @param {string}
|
|
24
|
+
*/
|
|
25
|
+
entry?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The path to the output directory.
|
|
28
|
+
* @param {string}
|
|
29
|
+
*/
|
|
30
|
+
outputPath?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The public path of the application.
|
|
33
|
+
* @param {string}
|
|
34
|
+
*/
|
|
35
|
+
publicPath?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Whether to append a hash to the output file name for cache busting.
|
|
38
|
+
* @param {boolean}
|
|
39
|
+
*/
|
|
40
|
+
hash?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* An object mapping module names to global variables.
|
|
43
|
+
* @param {Record<string, string>}
|
|
44
|
+
*/
|
|
45
|
+
externals?: Record<string, string>;
|
|
46
|
+
/**
|
|
47
|
+
* An array of plugin configurations.
|
|
48
|
+
* @param {HookOptions[]}
|
|
49
|
+
*/
|
|
50
|
+
plugins?: HookOptions[];
|
|
51
|
+
/**
|
|
52
|
+
* The path to the HTML template to use for the application.
|
|
53
|
+
* @param {string}
|
|
54
|
+
*/
|
|
55
|
+
htmlTemplate?: string;
|
|
56
|
+
htmlChunks?: 'all' | string[];
|
|
57
|
+
/**
|
|
58
|
+
* Whether to enable the bundle analyzer plugin.
|
|
59
|
+
* @param {boolean}
|
|
60
|
+
*/
|
|
61
|
+
analyzer?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* An array of additional PostCSS plugins to use.
|
|
64
|
+
* @param {Plugin[]}
|
|
65
|
+
*/
|
|
66
|
+
extraPostCSSPlugins?: Plugin[];
|
|
67
|
+
/**
|
|
68
|
+
* Options to pass to the Less compiler.
|
|
69
|
+
* @param {*}
|
|
70
|
+
*/
|
|
71
|
+
lessOptions?: any;
|
|
72
|
+
/**
|
|
73
|
+
* A function to dynamically resolve module requests.
|
|
74
|
+
* @param {Function}
|
|
75
|
+
*/
|
|
76
|
+
dynamicResolve?: <T extends any>(request: T) => T;
|
|
77
|
+
/**
|
|
78
|
+
* Whether to enable the auto-polyfills plugin, or an options object for the plugin.
|
|
79
|
+
* @param {string}
|
|
80
|
+
*/
|
|
81
|
+
autoPolyfills: boolean | AutoPolyfillsWebpackPluginOptions;
|
|
82
|
+
/**
|
|
83
|
+
* Options for the development server.
|
|
84
|
+
* @param {{proxy?: Record<string, any>, host: string, port: number, staticPath?: string, historyApiFallback?: any, compilationSuccessInfo?: { messages: string[]; notes?: string[] }}}
|
|
85
|
+
*/
|
|
86
|
+
serve: {
|
|
87
|
+
proxy?: Record<string, any>;
|
|
88
|
+
host: string;
|
|
89
|
+
port: number;
|
|
90
|
+
staticPath?: string;
|
|
91
|
+
historyApiFallback?: any;
|
|
92
|
+
compilationSuccessInfo?: {
|
|
93
|
+
messages: string[];
|
|
94
|
+
notes?: string[];
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Experimental features to enable.
|
|
99
|
+
* @param {{speedUp?: boolean, minimizer?: boolean, disableLazyImports?: boolean, enableCssModule?: boolean, compress?: any}}
|
|
100
|
+
*/
|
|
101
|
+
experiment?: {
|
|
102
|
+
speedUp?: boolean;
|
|
103
|
+
minimizer?: boolean;
|
|
104
|
+
disableLazyImports?: boolean;
|
|
105
|
+
enableCssModule?: boolean;
|
|
106
|
+
compress?: any;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Options for the linter plugins.
|
|
110
|
+
* @param {Record<IKeys, Omit<IOpts, 'write'>>}
|
|
111
|
+
*/
|
|
112
|
+
lints?: Record<IKeys, Omit<IOpts, 'write'>>;
|
|
113
|
+
};
|
|
114
|
+
export type ICliOptions = {
|
|
115
|
+
hash?: boolean;
|
|
116
|
+
analyzer?: boolean;
|
|
117
|
+
};
|
|
118
|
+
export type IWebpackOptions = IOptions & {
|
|
119
|
+
isProd: boolean;
|
|
120
|
+
} & ICliOptions;
|
|
121
|
+
export type HookItem = {
|
|
122
|
+
name: string;
|
|
123
|
+
fn: Function;
|
|
124
|
+
stage?: number;
|
|
125
|
+
before?: string;
|
|
126
|
+
};
|
|
127
|
+
export declare enum ACTION {
|
|
128
|
+
ADD = "add",
|
|
129
|
+
UPDATE = "update"
|
|
130
|
+
}
|
|
131
|
+
export declare enum HOOK_KEY_SET {
|
|
132
|
+
WEBPACK_PLUGIN = "WebpackPlugin",
|
|
133
|
+
MODIFY_WEBPACK = "ModifyWebpack"
|
|
134
|
+
}
|
|
135
|
+
export type HookOptions = {
|
|
136
|
+
key: string;
|
|
137
|
+
action: ACTION;
|
|
138
|
+
opts: HookItem;
|
|
139
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Compiler } from 'webpack';
|
|
2
|
+
declare class PurgeCacheWebpackPlugin {
|
|
3
|
+
WEBPACK_PLUGIN_NAME: string;
|
|
4
|
+
purgeCacheFiles(directory: string, maxAge: number, callback: (errors?: Error[]) => void): void;
|
|
5
|
+
apply(compiler: Compiler): void;
|
|
6
|
+
}
|
|
7
|
+
export default PurgeCacheWebpackPlugin;
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
class PurgeCacheWebpackPlugin {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.WEBPACK_PLUGIN_NAME = 'PurgeCacheWebpackPlugin';
|
|
11
|
+
}
|
|
12
|
+
purgeCacheFiles(directory, maxAge, callback) {
|
|
13
|
+
promises_1.default.readdir(directory)
|
|
14
|
+
.then(files => {
|
|
15
|
+
const expiredPacks = [];
|
|
16
|
+
if (files.length === 0)
|
|
17
|
+
return callback();
|
|
18
|
+
for (const file of files) {
|
|
19
|
+
const pack = new Promise((resolve, reject) => {
|
|
20
|
+
const filePath = path_1.default.join(directory, file);
|
|
21
|
+
promises_1.default.stat(filePath)
|
|
22
|
+
.then(stats => {
|
|
23
|
+
if (stats.mtime.getTime() + maxAge < Date.now()) {
|
|
24
|
+
promises_1.default.unlink(filePath)
|
|
25
|
+
.then(() => {
|
|
26
|
+
resolve(true);
|
|
27
|
+
})
|
|
28
|
+
.catch(err => reject(err));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
resolve(true);
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
.catch(err => reject(err));
|
|
35
|
+
});
|
|
36
|
+
expiredPacks.push(pack);
|
|
37
|
+
}
|
|
38
|
+
Promise.allSettled(expiredPacks).then(results => {
|
|
39
|
+
const errors = results
|
|
40
|
+
.filter(result => result.status === 'rejected')
|
|
41
|
+
.map((result) => result.reason);
|
|
42
|
+
callback(errors);
|
|
43
|
+
});
|
|
44
|
+
})
|
|
45
|
+
.catch(err => {
|
|
46
|
+
callback([err]);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
apply(compiler) {
|
|
50
|
+
compiler.hooks.done.tapAsync({ name: this.WEBPACK_PLUGIN_NAME }, (_, callback) => {
|
|
51
|
+
const { type, maxAge, cacheLocation } = compiler.options.cache;
|
|
52
|
+
if (type === 'filesystem') {
|
|
53
|
+
const logger = compiler.getInfrastructureLogger(this.WEBPACK_PLUGIN_NAME);
|
|
54
|
+
this.purgeCacheFiles(cacheLocation, maxAge, errors => {
|
|
55
|
+
if (errors?.length) {
|
|
56
|
+
errors.forEach(err => logger.warn(err.message));
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
logger.info(`purge expired cache files completed`);
|
|
60
|
+
}
|
|
61
|
+
callback();
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
callback();
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.default = PurgeCacheWebpackPlugin;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Configuration, FileCacheOptions } from 'webpack';
|
|
2
|
+
import Service from '../core/service';
|
|
3
|
+
declare class WebpackConfig {
|
|
4
|
+
private extensions;
|
|
5
|
+
private opts;
|
|
6
|
+
private env;
|
|
7
|
+
constructor(service: Service);
|
|
8
|
+
merge(...opts: Configuration[]): Configuration;
|
|
9
|
+
get cache(): FileCacheOptions;
|
|
10
|
+
get projectVersion(): string;
|
|
11
|
+
get base(): Configuration;
|
|
12
|
+
get isProd(): boolean;
|
|
13
|
+
}
|
|
14
|
+
export default WebpackConfig;
|
package/lib/webpack/index.js
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { IWebpackOptions } from '../../../types';
|
|
2
|
+
declare class BabelLoader {
|
|
3
|
+
private BABEL_LOADER;
|
|
4
|
+
private opts;
|
|
5
|
+
private speedUp;
|
|
6
|
+
constructor(opts: IWebpackOptions);
|
|
7
|
+
get config(): {
|
|
8
|
+
loader: string;
|
|
9
|
+
options: {
|
|
10
|
+
presets: (string | {
|
|
11
|
+
useAbsoluteRuntime: boolean;
|
|
12
|
+
})[][];
|
|
13
|
+
plugins: ((string | {
|
|
14
|
+
libraryName: string;
|
|
15
|
+
libraryDirectory: string;
|
|
16
|
+
style: string;
|
|
17
|
+
})[] | (string | {
|
|
18
|
+
libraryName: string;
|
|
19
|
+
libraryDirectory: string;
|
|
20
|
+
camel2DashComponentName: string;
|
|
21
|
+
})[])[];
|
|
22
|
+
babelrc: boolean;
|
|
23
|
+
configFile: boolean;
|
|
24
|
+
cacheIdentifier: string;
|
|
25
|
+
cacheDirectory: boolean;
|
|
26
|
+
cacheCompression: boolean;
|
|
27
|
+
compact: boolean;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
get treasurePluginConfig(): ((string | {
|
|
31
|
+
libraryName: string;
|
|
32
|
+
libraryDirectory: string;
|
|
33
|
+
style: string;
|
|
34
|
+
})[] | (string | {
|
|
35
|
+
libraryName: string;
|
|
36
|
+
libraryDirectory: string;
|
|
37
|
+
camel2DashComponentName: string;
|
|
38
|
+
})[])[];
|
|
39
|
+
get plugins(): ((string | {
|
|
40
|
+
libraryName: string;
|
|
41
|
+
libraryDirectory: string;
|
|
42
|
+
style: string;
|
|
43
|
+
})[] | (string | {
|
|
44
|
+
libraryName: string;
|
|
45
|
+
libraryDirectory: string;
|
|
46
|
+
camel2DashComponentName: string;
|
|
47
|
+
})[])[];
|
|
48
|
+
get cacheIdentifier(): string;
|
|
49
|
+
}
|
|
50
|
+
export default BabelLoader;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { IWebpackOptions } from '../../types';
|
|
2
|
+
declare const loaders: (opts: IWebpackOptions) => (false | {
|
|
3
|
+
test: RegExp;
|
|
4
|
+
type: string;
|
|
5
|
+
generator: {
|
|
6
|
+
filename: string;
|
|
7
|
+
};
|
|
8
|
+
} | {
|
|
9
|
+
test: RegExp;
|
|
10
|
+
use: {
|
|
11
|
+
loader: string;
|
|
12
|
+
}[];
|
|
13
|
+
exclude?: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
test: RegExp;
|
|
16
|
+
exclude: (input: string) => boolean;
|
|
17
|
+
use: {
|
|
18
|
+
loader: string;
|
|
19
|
+
}[];
|
|
20
|
+
} | {
|
|
21
|
+
test: RegExp;
|
|
22
|
+
loader: string;
|
|
23
|
+
include: (input: string) => boolean;
|
|
24
|
+
options: {
|
|
25
|
+
inline: string;
|
|
26
|
+
};
|
|
27
|
+
use?: undefined;
|
|
28
|
+
} | {
|
|
29
|
+
test: RegExp;
|
|
30
|
+
include: (input: string) => boolean;
|
|
31
|
+
use: ({
|
|
32
|
+
loader: string;
|
|
33
|
+
options: {
|
|
34
|
+
presets: (string | {
|
|
35
|
+
useAbsoluteRuntime: boolean;
|
|
36
|
+
})[][];
|
|
37
|
+
plugins: ((string | {
|
|
38
|
+
libraryName: string;
|
|
39
|
+
libraryDirectory: string;
|
|
40
|
+
style: string;
|
|
41
|
+
})[] | (string | {
|
|
42
|
+
libraryName: string;
|
|
43
|
+
libraryDirectory: string;
|
|
44
|
+
camel2DashComponentName: string;
|
|
45
|
+
})[])[];
|
|
46
|
+
babelrc: boolean;
|
|
47
|
+
configFile: boolean;
|
|
48
|
+
cacheIdentifier: string;
|
|
49
|
+
cacheDirectory: boolean;
|
|
50
|
+
cacheCompression: boolean;
|
|
51
|
+
compact: boolean;
|
|
52
|
+
};
|
|
53
|
+
} | {
|
|
54
|
+
loader: string;
|
|
55
|
+
options: {
|
|
56
|
+
name: string;
|
|
57
|
+
loader?: undefined;
|
|
58
|
+
target?: undefined;
|
|
59
|
+
};
|
|
60
|
+
} | {
|
|
61
|
+
loader: string;
|
|
62
|
+
options: {
|
|
63
|
+
loader: string;
|
|
64
|
+
target: string;
|
|
65
|
+
name?: undefined;
|
|
66
|
+
};
|
|
67
|
+
})[];
|
|
68
|
+
loader?: undefined;
|
|
69
|
+
options?: undefined;
|
|
70
|
+
} | undefined)[];
|
|
71
|
+
export default loaders;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { IWebpackOptions } from '../../types';
|
|
2
|
+
declare class Script {
|
|
3
|
+
private THREAD_LOADER;
|
|
4
|
+
private WORKER_LOADER;
|
|
5
|
+
private ESBUILD_LOADER;
|
|
6
|
+
private BABEL_LOADER;
|
|
7
|
+
private opts;
|
|
8
|
+
constructor(opts: IWebpackOptions);
|
|
9
|
+
get config(): ({
|
|
10
|
+
test: RegExp;
|
|
11
|
+
loader: string;
|
|
12
|
+
include: (input: string) => boolean;
|
|
13
|
+
options: {
|
|
14
|
+
inline: string;
|
|
15
|
+
};
|
|
16
|
+
use?: undefined;
|
|
17
|
+
} | {
|
|
18
|
+
test: RegExp;
|
|
19
|
+
include: (input: string) => boolean;
|
|
20
|
+
use: ({
|
|
21
|
+
loader: string;
|
|
22
|
+
options: {
|
|
23
|
+
presets: (string | {
|
|
24
|
+
useAbsoluteRuntime: boolean;
|
|
25
|
+
})[][];
|
|
26
|
+
plugins: ((string | {
|
|
27
|
+
libraryName: string;
|
|
28
|
+
libraryDirectory: string;
|
|
29
|
+
style: string;
|
|
30
|
+
})[] | (string | {
|
|
31
|
+
libraryName: string;
|
|
32
|
+
libraryDirectory: string;
|
|
33
|
+
camel2DashComponentName: string;
|
|
34
|
+
})[])[];
|
|
35
|
+
babelrc: boolean;
|
|
36
|
+
configFile: boolean;
|
|
37
|
+
cacheIdentifier: string;
|
|
38
|
+
cacheDirectory: boolean;
|
|
39
|
+
cacheCompression: boolean;
|
|
40
|
+
compact: boolean;
|
|
41
|
+
};
|
|
42
|
+
} | {
|
|
43
|
+
loader: string;
|
|
44
|
+
options: {
|
|
45
|
+
name: string;
|
|
46
|
+
loader?: undefined;
|
|
47
|
+
target?: undefined;
|
|
48
|
+
};
|
|
49
|
+
} | {
|
|
50
|
+
loader: string;
|
|
51
|
+
options: {
|
|
52
|
+
loader: string;
|
|
53
|
+
target: string;
|
|
54
|
+
name?: undefined;
|
|
55
|
+
};
|
|
56
|
+
})[];
|
|
57
|
+
loader?: undefined;
|
|
58
|
+
options?: undefined;
|
|
59
|
+
})[];
|
|
60
|
+
}
|
|
61
|
+
export default Script;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { IWebpackOptions } from '../../types';
|
|
2
|
+
declare class Style {
|
|
3
|
+
private STYLE_LOADER;
|
|
4
|
+
private CSS_LOADER;
|
|
5
|
+
private SASS_LOADER;
|
|
6
|
+
private LESS_LOADER;
|
|
7
|
+
private POSTCSS_LOADER;
|
|
8
|
+
private CSS_MODULE_FILE_SUFFIX_REGEX;
|
|
9
|
+
private opts;
|
|
10
|
+
constructor(opts: IWebpackOptions);
|
|
11
|
+
get config(): (false | {
|
|
12
|
+
test: RegExp;
|
|
13
|
+
use: {
|
|
14
|
+
loader: string;
|
|
15
|
+
}[];
|
|
16
|
+
exclude?: undefined;
|
|
17
|
+
} | {
|
|
18
|
+
test: RegExp;
|
|
19
|
+
exclude: (input: string) => boolean;
|
|
20
|
+
use: {
|
|
21
|
+
loader: string;
|
|
22
|
+
}[];
|
|
23
|
+
} | undefined)[];
|
|
24
|
+
get sassCssModuleConfig(): {
|
|
25
|
+
test: RegExp;
|
|
26
|
+
use: ({
|
|
27
|
+
loader: string;
|
|
28
|
+
} | {
|
|
29
|
+
loader: string;
|
|
30
|
+
options: {
|
|
31
|
+
esModule: boolean;
|
|
32
|
+
modules: {
|
|
33
|
+
namedExport: boolean;
|
|
34
|
+
localIdentName: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
})[];
|
|
38
|
+
};
|
|
39
|
+
get styleLoader(): {
|
|
40
|
+
loader: string;
|
|
41
|
+
};
|
|
42
|
+
get cssLoader(): {
|
|
43
|
+
loader: string;
|
|
44
|
+
options: {
|
|
45
|
+
sourceMap: boolean;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
get sassLoader(): {
|
|
49
|
+
loader: string;
|
|
50
|
+
options: {
|
|
51
|
+
sourceMap: boolean;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
get lessLoader(): {
|
|
55
|
+
loader: string;
|
|
56
|
+
options: {
|
|
57
|
+
sourceMap: boolean;
|
|
58
|
+
lessOptions: any;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
get postCSSLoader(): {
|
|
62
|
+
loader: string;
|
|
63
|
+
options: {
|
|
64
|
+
sourceMap: boolean;
|
|
65
|
+
postcssOptions: {
|
|
66
|
+
plugins: any[];
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
get postCSSPlugins(): any[];
|
|
71
|
+
}
|
|
72
|
+
export default Style;
|
package/lib/webpack/plugins.js
CHANGED
|
@@ -14,7 +14,7 @@ const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
|
|
|
14
14
|
const webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
|
|
15
15
|
const auto_polyfills_webpack_plugin_1 = __importDefault(require("@dtinsight/auto-polyfills-webpack-plugin"));
|
|
16
16
|
const friendly_errors_webpack_plugin_1 = __importDefault(require("@nuxt/friendly-errors-webpack-plugin"));
|
|
17
|
-
const
|
|
17
|
+
const purge_cache_webpack_plugin_1 = __importDefault(require("./custom-plugins/purge-cache-webpack-plugin"));
|
|
18
18
|
function getPlugins(opts) {
|
|
19
19
|
const { isProd, htmlTemplate, htmlChunks, copy, analyzer, autoPolyfills, serve: { host, port, compilationSuccessInfo }, } = opts;
|
|
20
20
|
const htmlOptions = {
|
|
@@ -92,7 +92,7 @@ function getPlugins(opts) {
|
|
|
92
92
|
notes: [],
|
|
93
93
|
},
|
|
94
94
|
}),
|
|
95
|
-
!isProd && new
|
|
95
|
+
!isProd && new purge_cache_webpack_plugin_1.default(),
|
|
96
96
|
isProd &&
|
|
97
97
|
autoPolyfills &&
|
|
98
98
|
(typeof autoPolyfills === 'boolean'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ko",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.6.0-beta.1",
|
|
4
4
|
"description": "build & lint library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ko",
|
|
@@ -34,16 +34,22 @@
|
|
|
34
34
|
"files": [
|
|
35
35
|
"lib/*"
|
|
36
36
|
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"prepublishOnly": "rm -rf lib && tsc",
|
|
39
|
+
"debug": "tsc -w --sourceMap",
|
|
40
|
+
"test": "jest",
|
|
41
|
+
"build": "tsc"
|
|
42
|
+
},
|
|
37
43
|
"dependencies": {
|
|
38
44
|
"@babel/core": "^7.18.0",
|
|
39
|
-
"@dtinsight/auto-polyfills-webpack-plugin": "2.0.0",
|
|
45
|
+
"@dtinsight/auto-polyfills-webpack-plugin": "workspace:2.0.0",
|
|
40
46
|
"@nuxt/friendly-errors-webpack-plugin": "^2.5.2",
|
|
41
47
|
"@parcel/css": "^1.12.2",
|
|
42
48
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
|
|
43
49
|
"autoprefixer": "^10.4.7",
|
|
44
50
|
"babel-loader": "^8.2.5",
|
|
45
51
|
"babel-plugin-treasure": "^0.9.0",
|
|
46
|
-
"babel-preset-ko-app": "
|
|
52
|
+
"babel-preset-ko-app": "workspace:^1.0.0",
|
|
47
53
|
"buffer": "^6.0.3",
|
|
48
54
|
"case-sensitive-paths-webpack-plugin": "^2.4.0",
|
|
49
55
|
"chalk": "^4.1.2",
|
|
@@ -54,12 +60,11 @@
|
|
|
54
60
|
"css-loader": "^6.7.1",
|
|
55
61
|
"css-minimizer-webpack-plugin": "^4.0.0",
|
|
56
62
|
"detect-port": "^1.3.0",
|
|
57
|
-
"dynamic-resolve-webpack-plugin": "
|
|
58
|
-
"error-overlay-webpack-plugin": "^1.1.1",
|
|
63
|
+
"dynamic-resolve-webpack-plugin": "workspace:^2.0.0",
|
|
59
64
|
"esbuild-loader": "^2.19.0",
|
|
60
65
|
"html-webpack-plugin": "^5.5.0",
|
|
61
66
|
"inquirer": "^8.2.2",
|
|
62
|
-
"ko-lints": "
|
|
67
|
+
"ko-lints": "workspace:^4.0.0",
|
|
63
68
|
"less": "^3.13.1",
|
|
64
69
|
"less-loader": "^9.1.0",
|
|
65
70
|
"lodash": "^4.17.21",
|
|
@@ -80,7 +85,7 @@
|
|
|
80
85
|
"thread-loader": "^3.0.4",
|
|
81
86
|
"webpack": "^5.72.1",
|
|
82
87
|
"webpack-bundle-analyzer": "^4.5.0",
|
|
83
|
-
"webpack-dev-server": "4.
|
|
88
|
+
"webpack-dev-server": "4.14.0",
|
|
84
89
|
"webpackbar": "^5.0.2",
|
|
85
90
|
"worker-loader": "^3.0.8"
|
|
86
91
|
},
|
|
@@ -97,11 +102,5 @@
|
|
|
97
102
|
},
|
|
98
103
|
"engines": {
|
|
99
104
|
"node": ">=14"
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
"debug": "tsc -w --sourceMap",
|
|
103
|
-
"test": "jest",
|
|
104
|
-
"build": "tsc"
|
|
105
|
-
},
|
|
106
|
-
"readme": "# ko\nEnglish | [简体中文](./README_CN.md)\n## Simple, yet powerful, tool for managing your react applications. \n\n<a href=\"https://www.npmjs.com/package/ko\"><img alt=\"NPM Status\" src=\"https://img.shields.io/npm/v/ko.svg?style=flat\"></a>\n\n## Features\n\n* Support building applications on top of **webpack v5** and **esbuild**\n* Customize ko to work exactly the way you need it for your applications \n* Built-in popular linting tools to lint your source code\n* Built-in support typescript\n\n## Installation\n\nYou can install ko using npm, yarn or pnpm:\n``` bash\nnpm install ko --save-dev\n# or\nyarn add ko --dev\n# or \npnpm add ko --save-dev\n```\n\n## Documents\n* [Introduction](https://dtstack.github.io/ko/zh-CN/docs/current/introduction)\n* [Getting Started](https://dtstack.github.io/ko/zh-CN/docs/current/getting-started)\n* [FAQ](https://dtstack.github.io/ko/zh-CN/docs/current/FAQ)\n\n## Contributing\n\nWe'd love to have your helping hand on `ko`! See [CONTRIBUTING](../../CONTRIBUTING.md) for more information on how to get started.\n\n## License\n\nCopyright © DTStack. All rights reserved.\n\nLicensed under the MIT license.\n"
|
|
107
|
-
}
|
|
105
|
+
}
|
|
106
|
+
}
|