@moneko/core 3.0.0-beta.82 → 3.0.0-beta.84
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/app.js +27 -1
- package/lib/cleanup.js +19 -1
- package/lib/common.js +214 -2
- package/lib/coverage.js +30 -1
- package/lib/define.d.ts +1 -3
- package/lib/define.js +9 -1
- package/lib/docs.js +118 -1
- package/lib/done.js +12 -1
- package/lib/esm.js +7 -1
- package/lib/generate-api.js +331 -1
- package/lib/has-pkg.js +14 -1
- package/lib/html-add-entry-attr.js +24 -1
- package/lib/html-plugin-option.js +44 -1
- package/lib/index.js +3 -1
- package/lib/minify.js +46 -1
- package/lib/modifyVars.js +11 -1
- package/lib/module-federation.js +46 -1
- package/lib/module.config.js +211 -1
- package/lib/net.js +33 -1
- package/lib/object-listener.js +28 -1
- package/lib/process-env.js +65 -1
- package/lib/resolver-sync.js +21 -1
- package/lib/routes.d.ts +1 -2
- package/lib/routes.js +171 -1
- package/lib/seo.js +59 -1
- package/lib/swcrc.js +105 -1
- package/lib/tsloader.config.js +25 -1
- package/lib/utils.js +49 -1
- package/lib/virtual-module-plugin.js +26 -1
- package/lib/virtual-modules.js +30 -1
- package/lib/webpack.common.js +230 -1
- package/lib/webpack.dev.js +92 -3
- package/lib/webpack.prod.js +66 -1
- package/lib/yarn-argv.js +9 -1
- package/package.json +2 -2
package/lib/app.js
CHANGED
|
@@ -1 +1,27 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { CONFIG } from './common.js';
|
|
4
|
+
import htmlPluginOption from './html-plugin-option.js';
|
|
5
|
+
import { APPTYPE, PACKAGENAME, PROGRAMPATH, programInfo } from './process-env.js';
|
|
6
|
+
import { toUpperCaseString } from './utils.js';
|
|
7
|
+
const entryName = APPTYPE === 'library' ? 'site' : 'src';
|
|
8
|
+
const app = {
|
|
9
|
+
base: CONFIG.routeBaseName,
|
|
10
|
+
designSize: CONFIG.designSize,
|
|
11
|
+
routerMode: CONFIG.routerMode,
|
|
12
|
+
mode: CONFIG.mode,
|
|
13
|
+
name: programInfo.name,
|
|
14
|
+
description: programInfo.description,
|
|
15
|
+
version: programInfo.version,
|
|
16
|
+
author: programInfo.author,
|
|
17
|
+
repository: programInfo.repository,
|
|
18
|
+
locales: fs.existsSync(path.join(PROGRAMPATH, `./${entryName}/locales`)),
|
|
19
|
+
favicon: htmlPluginOption.favicon,
|
|
20
|
+
prefixCls: CONFIG.prefixCls,
|
|
21
|
+
theme: CONFIG.theme,
|
|
22
|
+
type: APPTYPE,
|
|
23
|
+
persist: fs.existsSync(path.join(PROGRAMPATH, `./${entryName}/persist.ts`)),
|
|
24
|
+
projectName: JSON.stringify(toUpperCaseString(PACKAGENAME)),
|
|
25
|
+
iconfont: CONFIG.iconfont
|
|
26
|
+
};
|
|
27
|
+
export default app;
|
package/lib/cleanup.js
CHANGED
|
@@ -1 +1,19 @@
|
|
|
1
|
-
import{existsSync
|
|
1
|
+
import { existsSync, readdirSync, rmdirSync, statSync, unlinkSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { cacheDir } from './process-env.js';
|
|
4
|
+
function cleanDir(folderPath) {
|
|
5
|
+
if (existsSync(folderPath)) {
|
|
6
|
+
readdirSync(folderPath).forEach((file)=>{
|
|
7
|
+
const filePath = join(folderPath, file);
|
|
8
|
+
if (statSync(filePath).isDirectory()) {
|
|
9
|
+
cleanDir(filePath);
|
|
10
|
+
} else {
|
|
11
|
+
unlinkSync(filePath);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
rmdirSync(folderPath);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
process.on('SIGINT', function() {
|
|
18
|
+
cleanDir(cacheDir);
|
|
19
|
+
});
|
package/lib/common.js
CHANGED
|
@@ -1,4 +1,208 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import readline from 'readline';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { merge } from 'webpack-merge';
|
|
6
|
+
import { APPTYPE, CUSTOMCONFIG, FRAMEWORK, PROGRAMPATH, jsxImportSource, pkgName } from './process-env.js';
|
|
7
|
+
import { isFunction, readConf } from './utils.js';
|
|
8
|
+
export const ENTRYPATH = {
|
|
9
|
+
mobile: 'mobile',
|
|
10
|
+
site: 'site',
|
|
11
|
+
'back-stage': 'back-stage',
|
|
12
|
+
'single-spa': 'single-spa',
|
|
13
|
+
library: 'library',
|
|
14
|
+
'single-component': 'single-component'
|
|
15
|
+
};
|
|
16
|
+
const includeModule = [
|
|
17
|
+
`@moneko/${FRAMEWORK}`,
|
|
18
|
+
'neko-ui',
|
|
19
|
+
'antd',
|
|
20
|
+
'@antv',
|
|
21
|
+
'katex',
|
|
22
|
+
'font-pingfang-sc',
|
|
23
|
+
'font-pingfang-tc',
|
|
24
|
+
'react-photo-view',
|
|
25
|
+
'react-markdown-editor-lite',
|
|
26
|
+
'schema-design',
|
|
27
|
+
'@app'
|
|
28
|
+
];
|
|
29
|
+
let defaultSplitChunk = {
|
|
30
|
+
chunks: 'all',
|
|
31
|
+
minSize: 1024,
|
|
32
|
+
minChunks: 1,
|
|
33
|
+
cacheGroups: {
|
|
34
|
+
route: {
|
|
35
|
+
test: /[\\/].git[\\/]router/,
|
|
36
|
+
priority: -10,
|
|
37
|
+
reuseExistingChunk: true,
|
|
38
|
+
name: 'route'
|
|
39
|
+
},
|
|
40
|
+
example: {
|
|
41
|
+
test: /[\\/].git[\\/]example/,
|
|
42
|
+
priority: -10,
|
|
43
|
+
reuseExistingChunk: true,
|
|
44
|
+
name: 'example'
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
if (APPTYPE === 'single-component') {
|
|
49
|
+
defaultSplitChunk = false;
|
|
50
|
+
}
|
|
51
|
+
const defaultConfig = {
|
|
52
|
+
seo: false,
|
|
53
|
+
mode: 'csr',
|
|
54
|
+
compiler: 'swc',
|
|
55
|
+
bundleAnalyzer: {
|
|
56
|
+
analyzerMode: 'static',
|
|
57
|
+
reportFilename: 'report.html',
|
|
58
|
+
openAnalyzer: false
|
|
59
|
+
},
|
|
60
|
+
entry: {},
|
|
61
|
+
minifier: {
|
|
62
|
+
js: {},
|
|
63
|
+
css: {}
|
|
64
|
+
},
|
|
65
|
+
sourceMap: {
|
|
66
|
+
filename: '[file].map',
|
|
67
|
+
publicPath: ''
|
|
68
|
+
},
|
|
69
|
+
env: {},
|
|
70
|
+
routeBaseName: '/',
|
|
71
|
+
publicPath: '/',
|
|
72
|
+
designSize: APPTYPE === 'mobile' ? 375 : 1680,
|
|
73
|
+
fallbackCompPath: null,
|
|
74
|
+
modifyVars: {},
|
|
75
|
+
prefixCls: 'n',
|
|
76
|
+
alias: {},
|
|
77
|
+
layoutSider: {},
|
|
78
|
+
moduleRules: [],
|
|
79
|
+
prefixJsLoader: [],
|
|
80
|
+
cssModules: [],
|
|
81
|
+
importOnDemand: {},
|
|
82
|
+
proxy: [],
|
|
83
|
+
cacheDirectory: `${PROGRAMPATH}/node_modules/.temp_cache`,
|
|
84
|
+
devServer: {
|
|
85
|
+
allowedHosts: [
|
|
86
|
+
'.baidu.com'
|
|
87
|
+
],
|
|
88
|
+
host: 'localhost',
|
|
89
|
+
port: 3000,
|
|
90
|
+
https: false,
|
|
91
|
+
compress: false
|
|
92
|
+
},
|
|
93
|
+
htmlPluginOption: {
|
|
94
|
+
template: `./node_modules/${pkgName}/template/index.html`,
|
|
95
|
+
favicon: `./node_modules/${pkgName}/template/favicon.ico`,
|
|
96
|
+
tags: []
|
|
97
|
+
},
|
|
98
|
+
assetHtml: [],
|
|
99
|
+
routerMode: 'browser',
|
|
100
|
+
fixBrowserRouter: false,
|
|
101
|
+
plugins: [],
|
|
102
|
+
splitChunk: defaultSplitChunk,
|
|
103
|
+
runtimeChunk: APPTYPE === 'single-component' ? false : 'single',
|
|
104
|
+
moduleFederation: [],
|
|
105
|
+
rulesInclude: {
|
|
106
|
+
less: includeModule,
|
|
107
|
+
css: includeModule,
|
|
108
|
+
js: includeModule,
|
|
109
|
+
media: includeModule,
|
|
110
|
+
fonts: includeModule
|
|
111
|
+
},
|
|
112
|
+
mdx: {
|
|
113
|
+
jsxImportSource: jsxImportSource,
|
|
114
|
+
useDynamicImport: true,
|
|
115
|
+
remarkPlugins: [],
|
|
116
|
+
rehypePlugins: []
|
|
117
|
+
},
|
|
118
|
+
jsxDomExpressions: {
|
|
119
|
+
moduleName: 'solid-js/web',
|
|
120
|
+
builtIns: [
|
|
121
|
+
'For',
|
|
122
|
+
'Show',
|
|
123
|
+
'Switch',
|
|
124
|
+
'Match',
|
|
125
|
+
'Suspense',
|
|
126
|
+
'SuspenseList',
|
|
127
|
+
'Portal',
|
|
128
|
+
'Index',
|
|
129
|
+
'Dynamic',
|
|
130
|
+
'ErrorBoundary'
|
|
131
|
+
],
|
|
132
|
+
contextToCustomElements: true,
|
|
133
|
+
wrapConditionals: true,
|
|
134
|
+
generate: 'dom',
|
|
135
|
+
hydratable: false
|
|
136
|
+
},
|
|
137
|
+
bar: {
|
|
138
|
+
name: '编译中',
|
|
139
|
+
color: '#6f42c1'
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
export const log = (msg)=>{
|
|
143
|
+
readline.cursorTo(process.stdout, 0);
|
|
144
|
+
process.stdout.write(msg);
|
|
145
|
+
};
|
|
146
|
+
let customConf = defaultConfig;
|
|
147
|
+
let configPath = null;
|
|
148
|
+
let normalConf = {};
|
|
149
|
+
let envConf = {};
|
|
150
|
+
try {
|
|
151
|
+
configPath = path.join(PROGRAMPATH, './config/index.ts');
|
|
152
|
+
fs.accessSync(configPath, fs.constants.R_OK);
|
|
153
|
+
} catch (error) {
|
|
154
|
+
configPath = null;
|
|
155
|
+
}
|
|
156
|
+
if (configPath) {
|
|
157
|
+
try {
|
|
158
|
+
const conf = (await readConf(configPath, 'index')).default;
|
|
159
|
+
normalConf = isFunction(conf) ? conf(process) : conf;
|
|
160
|
+
} catch (error) {
|
|
161
|
+
process.stdout.write(chalk.red(error));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (CUSTOMCONFIG) {
|
|
165
|
+
let customConfigPath = null;
|
|
166
|
+
try {
|
|
167
|
+
customConfigPath = path.join(PROGRAMPATH, `./config/${CUSTOMCONFIG}.ts`);
|
|
168
|
+
fs.accessSync(customConfigPath, fs.constants.R_OK);
|
|
169
|
+
} catch (error) {
|
|
170
|
+
customConfigPath = null;
|
|
171
|
+
}
|
|
172
|
+
if (customConfigPath !== null) {
|
|
173
|
+
try {
|
|
174
|
+
const conf = (await readConf(customConfigPath, CUSTOMCONFIG)).default;
|
|
175
|
+
envConf = isFunction(conf) ? conf(process) : conf;
|
|
176
|
+
} catch (error) {
|
|
177
|
+
process.stdout.write(chalk.red(error));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
customConf = merge(customConf, normalConf, envConf);
|
|
182
|
+
if (customConf.compiler === 'tsc' && customConf.minifier) {
|
|
183
|
+
if (!customConf.minifier.js) {
|
|
184
|
+
Object.assign(customConf.minifier, {
|
|
185
|
+
js: {
|
|
186
|
+
type: 'terser'
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
if (!customConf.minifier.css) {
|
|
191
|
+
Object.assign(customConf.minifier, {
|
|
192
|
+
css: {
|
|
193
|
+
type: 'cssnano'
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (customConf.devtool === false) customConf.sourceMap = false;
|
|
199
|
+
if (customConf.sourceMap === false) customConf.devtool = false;
|
|
200
|
+
if (customConf.fixBrowserRouter && customConf.htmlPluginOption) {
|
|
201
|
+
if (!customConf.htmlPluginOption.tags) {
|
|
202
|
+
customConf.htmlPluginOption.tags = [];
|
|
203
|
+
}
|
|
204
|
+
customConf.htmlPluginOption.tags.push({
|
|
205
|
+
textContent: `
|
|
2
206
|
(function(l) {
|
|
3
207
|
if (l.search[1] === '/' ) {
|
|
4
208
|
var decoded = l.search.slice(1).split('&').map(function(s) {
|
|
@@ -9,4 +213,12 @@ import e from"fs";import t from"path";import o from"readline";import s from"chal
|
|
|
9
213
|
);
|
|
10
214
|
}
|
|
11
215
|
}(window.location))
|
|
12
|
-
`
|
|
216
|
+
`
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
export const CONFIG = customConf;
|
|
220
|
+
export const PUBLICPATH = CONFIG.publicPath || '/';
|
|
221
|
+
global.NEKOCLICONFIG = {
|
|
222
|
+
CONFIG,
|
|
223
|
+
log
|
|
224
|
+
};
|
package/lib/coverage.js
CHANGED
|
@@ -1 +1,30 @@
|
|
|
1
|
-
import{accessSync
|
|
1
|
+
import { accessSync, constants, readFileSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { Parser } from 'xml2js';
|
|
4
|
+
import { PACKAGENAME, PROGRAMPATH } from './process-env.js';
|
|
5
|
+
export const coverage = {};
|
|
6
|
+
try {
|
|
7
|
+
const coveragePath = join(PROGRAMPATH, './coverage/clover.xml');
|
|
8
|
+
accessSync(coveragePath, constants.R_OK);
|
|
9
|
+
const parser = new Parser({
|
|
10
|
+
explicitArray: false,
|
|
11
|
+
async: false
|
|
12
|
+
});
|
|
13
|
+
const cover = readFileSync(coveragePath, {
|
|
14
|
+
encoding: 'utf-8'
|
|
15
|
+
});
|
|
16
|
+
parser.parseString(cover, (error, result)=>{
|
|
17
|
+
if (!error) {
|
|
18
|
+
const projectMetrics = result.coverage.project.metrics.$;
|
|
19
|
+
const components = result.coverage.project.package;
|
|
20
|
+
Object.assign(coverage, {
|
|
21
|
+
[PACKAGENAME]: projectMetrics
|
|
22
|
+
});
|
|
23
|
+
components.forEach((pkg)=>{
|
|
24
|
+
Object.assign(coverage, {
|
|
25
|
+
[pkg.$.name]: pkg.metrics.$
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
} catch (error) {}
|
package/lib/define.d.ts
CHANGED
package/lib/define.js
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
import{CONFIG
|
|
1
|
+
import { CONFIG } from './common.js';
|
|
2
|
+
import { NODE_ENV } from './process-env.js';
|
|
3
|
+
const define = {
|
|
4
|
+
'process.env': JSON.stringify({
|
|
5
|
+
NODE_ENV: NODE_ENV,
|
|
6
|
+
...CONFIG.env
|
|
7
|
+
})
|
|
8
|
+
};
|
|
9
|
+
export default define;
|
package/lib/docs.js
CHANGED
|
@@ -1 +1,118 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { statSync } from 'fs';
|
|
2
|
+
import { dirname, join } from 'path';
|
|
3
|
+
import { watch } from 'chokidar';
|
|
4
|
+
import generateApi from './generate-api.js';
|
|
5
|
+
import { APPTYPE, FRAMEWORK } from './process-env.js';
|
|
6
|
+
import { resolveNodeModulesPath, resolveProgramPath } from './utils.js';
|
|
7
|
+
import { vm } from './virtual-module-plugin.js';
|
|
8
|
+
import { alias } from './webpack.common.js';
|
|
9
|
+
const base = '@app/comment';
|
|
10
|
+
const apiEntry = '@app/docs';
|
|
11
|
+
export const envApi = {};
|
|
12
|
+
const cacheEnvApi = {
|
|
13
|
+
[base]: {}
|
|
14
|
+
};
|
|
15
|
+
const createElement = {
|
|
16
|
+
react: 'createElement',
|
|
17
|
+
'solid-js': 'createComponent'
|
|
18
|
+
}[FRAMEWORK];
|
|
19
|
+
let replaceStr = `() => ${createElement}(SuspenseComp, { comp: $1 })`;
|
|
20
|
+
let prefixStr = `import { ${createElement} } from "${FRAMEWORK}";import { SuspenseComp } from "@moneko/${FRAMEWORK}";`;
|
|
21
|
+
if (![
|
|
22
|
+
'react',
|
|
23
|
+
'solid-js'
|
|
24
|
+
].includes(FRAMEWORK)) {
|
|
25
|
+
replaceStr = '$1';
|
|
26
|
+
prefixStr = '';
|
|
27
|
+
}
|
|
28
|
+
if (FRAMEWORK === 'solid-js') {
|
|
29
|
+
prefixStr = `import { Dynamic } from "${FRAMEWORK}/web";${prefixStr}`;
|
|
30
|
+
}
|
|
31
|
+
function handleFileChange(filePath, changeType) {
|
|
32
|
+
const fil = filePath.replace(new RegExp(`^${alias['@pkg']}`), '');
|
|
33
|
+
const __dir = dirname(fil).replace(/^\//, '');
|
|
34
|
+
const apiDir = [
|
|
35
|
+
base,
|
|
36
|
+
__dir
|
|
37
|
+
].join('/');
|
|
38
|
+
const name = fil.split('/').pop()?.replace(/\.tsx?/, '.md');
|
|
39
|
+
if (!name) return;
|
|
40
|
+
if (!cacheEnvApi[base][__dir]) {
|
|
41
|
+
cacheEnvApi[base][__dir] = {};
|
|
42
|
+
}
|
|
43
|
+
const target = join(apiDir, name);
|
|
44
|
+
if (changeType === 'deleted') {
|
|
45
|
+
if (cacheEnvApi[base][__dir][name]) {
|
|
46
|
+
delete cacheEnvApi[base][__dir][name];
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
const api = generateApi(filePath);
|
|
50
|
+
cacheEnvApi[target] = api;
|
|
51
|
+
if (api) {
|
|
52
|
+
cacheEnvApi[base][__dir][name] = `rr(() => import(/* webpackChunkName: '${target}' */'${target}?raw').then((res) => ({default: ${createElement}(Dynamic, {text: res.default, component: 'n-md'})})))rr`;
|
|
53
|
+
} else if (cacheEnvApi[base][__dir][name]) {
|
|
54
|
+
delete cacheEnvApi[base][__dir][name];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const basestr = {};
|
|
58
|
+
for(const k in cacheEnvApi[base]){
|
|
59
|
+
if (Object.prototype.hasOwnProperty.call(cacheEnvApi[base], k)) {
|
|
60
|
+
basestr[k] = Object.values(cacheEnvApi[base][k]);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const env = {
|
|
64
|
+
...cacheEnvApi
|
|
65
|
+
};
|
|
66
|
+
delete env[base];
|
|
67
|
+
Object.assign(envApi, {
|
|
68
|
+
...env,
|
|
69
|
+
[apiEntry]: `${prefixStr}export default ${JSON.stringify(basestr).replace(/"rr\((.+?)\)rr"/g, replaceStr)}`
|
|
70
|
+
});
|
|
71
|
+
for(const key in envApi){
|
|
72
|
+
if (Object.prototype.hasOwnProperty.call(envApi, key)) {
|
|
73
|
+
vm?.writeModule(resolveNodeModulesPath(key), envApi[key]);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function watchDirectory() {
|
|
78
|
+
const files = [];
|
|
79
|
+
const watcher = watch(resolveProgramPath('components'), {
|
|
80
|
+
ignored: [
|
|
81
|
+
/(^|[\\/\\])\../,
|
|
82
|
+
/(^|[\\/\\])__tests__([\\/\\]|$)/
|
|
83
|
+
],
|
|
84
|
+
persistent: true,
|
|
85
|
+
ignoreInitial: false
|
|
86
|
+
});
|
|
87
|
+
function isTs(path) {
|
|
88
|
+
return /\.tsx?$/.test(path) && statSync(path).isFile();
|
|
89
|
+
}
|
|
90
|
+
watcher.on('add', (path)=>{
|
|
91
|
+
if (isTs(path)) {
|
|
92
|
+
handleFileChange(path, 'added');
|
|
93
|
+
files.push(path);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
watcher.on('change', (path)=>{
|
|
97
|
+
if (isTs(path)) {
|
|
98
|
+
handleFileChange(path, 'change');
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
watcher.on('unlink', (path)=>{
|
|
102
|
+
if (isTs(path)) {
|
|
103
|
+
handleFileChange(path, 'deleted');
|
|
104
|
+
files.splice(files.indexOf(path), 1);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
watcher.on('ready', ()=>{
|
|
108
|
+
files.forEach((f)=>{
|
|
109
|
+
handleFileChange(f, 'change');
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
process.on('SIGINT', function() {
|
|
113
|
+
watcher.close();
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
if (APPTYPE === 'library') {
|
|
117
|
+
watchDirectory();
|
|
118
|
+
}
|
package/lib/done.js
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
class DoneWebpackPlugin {
|
|
2
|
+
options;
|
|
3
|
+
constructor(options){
|
|
4
|
+
this.options = Object.assign({}, options);
|
|
5
|
+
}
|
|
6
|
+
apply(compiler) {
|
|
7
|
+
compiler.hooks.done.tap('DoneWebpackPlugin', ()=>{
|
|
8
|
+
this.options.done?.();
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export default DoneWebpackPlugin;
|
package/lib/esm.js
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
export default function
|
|
1
|
+
export default function esm(templateStrings, ...substitutions) {
|
|
2
|
+
let js = templateStrings.raw[0];
|
|
3
|
+
for(let i = 0; i < substitutions.length; i++){
|
|
4
|
+
js += substitutions[i] + templateStrings.raw[i + 1];
|
|
5
|
+
}
|
|
6
|
+
return `data:text/javascript;base64,${Buffer.from(js).toString('base64')}`;
|
|
7
|
+
}
|