@moneko/core 3.0.0-beta.8 → 3.0.0-beta.81

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 (101) hide show
  1. package/lib/app.d.ts +31 -0
  2. package/lib/app.js +27 -0
  3. package/lib/cleanup.js +19 -0
  4. package/{build → lib}/common.d.ts +1 -1
  5. package/lib/common.js +225 -0
  6. package/{build → lib}/coverage.d.ts +1 -1
  7. package/lib/coverage.js +30 -0
  8. package/lib/define.d.ts +6 -0
  9. package/lib/define.js +9 -0
  10. package/lib/docs.d.ts +1 -0
  11. package/lib/docs.js +118 -0
  12. package/{build → lib}/done.d.ts +2 -7
  13. package/lib/done.js +12 -0
  14. package/lib/esm.d.ts +1 -0
  15. package/lib/esm.js +7 -0
  16. package/lib/generate-api.d.ts +1 -0
  17. package/lib/generate-api.js +331 -0
  18. package/lib/has-pkg.js +14 -0
  19. package/lib/html-add-entry-attr.js +24 -0
  20. package/{build → lib}/html-plugin-option.d.ts +1 -1
  21. package/lib/html-plugin-option.js +44 -0
  22. package/lib/index.d.ts +3 -36
  23. package/lib/index.js +3 -1
  24. package/lib/loader/frontmatter.cjs +6 -0
  25. package/lib/minify.js +46 -0
  26. package/lib/modifyVars.js +11 -0
  27. package/lib/module-federation.js +46 -0
  28. package/lib/module.config.js +211 -0
  29. package/lib/net.d.ts +3 -0
  30. package/lib/net.js +33 -0
  31. package/lib/object-listener.d.ts +4 -0
  32. package/lib/object-listener.js +28 -0
  33. package/{build → lib}/process-env.d.ts +7 -3
  34. package/lib/process-env.js +65 -0
  35. package/lib/resolver-sync.js +21 -0
  36. package/lib/routes.d.ts +2 -0
  37. package/lib/routes.js +178 -0
  38. package/lib/seo.js +59 -0
  39. package/{build → lib}/swcrc.d.ts +1 -1
  40. package/lib/swcrc.js +105 -0
  41. package/{build → lib}/tsloader.config.d.ts +1 -1
  42. package/lib/tsloader.config.js +25 -0
  43. package/{build → lib}/utils.d.ts +9 -4
  44. package/lib/utils.js +49 -0
  45. package/lib/virtual-module-plugin.d.ts +12 -0
  46. package/lib/virtual-module-plugin.js +26 -0
  47. package/lib/virtual-modules.d.ts +34 -0
  48. package/lib/virtual-modules.js +30 -0
  49. package/{build → lib}/webpack.common.d.ts +3 -0
  50. package/lib/webpack.common.js +230 -0
  51. package/lib/webpack.dev.js +93 -0
  52. package/lib/webpack.prod.d.ts +3 -0
  53. package/lib/webpack.prod.js +66 -0
  54. package/lib/yarn-argv.js +9 -0
  55. package/package.json +28 -38
  56. package/template/index.html +38 -1
  57. package/typings/global.d.ts +38 -20
  58. package/build/common.js +0 -12
  59. package/build/coverage.js +0 -1
  60. package/build/done.js +0 -1
  61. package/build/envFlags.d.ts +0 -17
  62. package/build/envFlags.js +0 -1
  63. package/build/has-pkg.js +0 -1
  64. package/build/html-add-entry-attr.js +0 -1
  65. package/build/html-plugin-option.js +0 -1
  66. package/build/index.d.ts +0 -2
  67. package/build/index.js +0 -1
  68. package/build/minify.js +0 -1
  69. package/build/modifyVars.js +0 -1
  70. package/build/module-federation.js +0 -1
  71. package/build/module.config.js +0 -1
  72. package/build/process-env.js +0 -1
  73. package/build/resolver-sync.js +0 -1
  74. package/build/seo.js +0 -1
  75. package/build/swcrc.js +0 -1
  76. package/build/tsloader.config.js +0 -1
  77. package/build/utils.js +0 -1
  78. package/build/webpack.common.js +0 -1
  79. package/build/webpack.dev.d.ts +0 -2
  80. package/build/webpack.dev.js +0 -4
  81. package/build/webpack.prod.js +0 -1
  82. package/build/yarn-argv.js +0 -1
  83. package/lib/normalize.css +0 -254
  84. package/lib/packages/library/bootstrap.js +0 -1
  85. package/lib/packages/library/index.d.ts +0 -4
  86. package/lib/packages/library/index.js +0 -1
  87. package/lib/refresh-rem.d.ts +0 -0
  88. package/lib/refresh-rem.js +0 -1
  89. package/lib/router/index.d.ts +0 -52
  90. package/lib/router/index.js +0 -1
  91. /package/lib/{packages/library/bootstrap.d.ts → cleanup.d.ts} +0 -0
  92. /package/{build → lib}/has-pkg.d.ts +0 -0
  93. /package/{build → lib}/html-add-entry-attr.d.ts +0 -0
  94. /package/{build → lib}/minify.d.ts +0 -0
  95. /package/{build → lib}/modifyVars.d.ts +0 -0
  96. /package/{build → lib}/module-federation.d.ts +0 -0
  97. /package/{build → lib}/module.config.d.ts +0 -0
  98. /package/{build → lib}/resolver-sync.d.ts +0 -0
  99. /package/{build → lib}/seo.d.ts +0 -0
  100. /package/{build/webpack.prod.d.ts → lib/webpack.dev.d.ts} +0 -0
  101. /package/{build → lib}/yarn-argv.d.ts +0 -0
package/lib/app.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ declare const app: {
2
+ base: string;
3
+ designSize: number;
4
+ routerMode: "browser" | "hash" | "memory";
5
+ mode: "csr" | "ssr";
6
+ name: string;
7
+ description: string | undefined;
8
+ version: string;
9
+ author: {
10
+ name: string | undefined;
11
+ email: string | undefined;
12
+ url: string | undefined;
13
+ };
14
+ repository: {
15
+ type: string | undefined;
16
+ url: string | undefined;
17
+ directory: string | undefined;
18
+ };
19
+ locales: boolean;
20
+ favicon: string | false | undefined;
21
+ prefixCls: string | undefined;
22
+ theme: import("./index.js").Theme | undefined;
23
+ type: import("./index.js").AppType;
24
+ persist: boolean;
25
+ projectName: string;
26
+ iconfont: {
27
+ scriptUrl?: string | string[] | undefined;
28
+ extraCommonProps?: Record<string, any> | undefined;
29
+ } | undefined;
30
+ };
31
+ export default app;
package/lib/app.js ADDED
@@ -0,0 +1,27 @@
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 ADDED
@@ -0,0 +1,19 @@
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
+ });
@@ -1,4 +1,4 @@
1
- import type { AppType, ConfigType } from '../typings/global.d.ts';
1
+ import type { AppType, ConfigType } from '../typings/global.js';
2
2
  export declare const ENTRYPATH: Record<AppType, string>;
3
3
  export declare const log: (msg: string) => void;
4
4
  export declare const CONFIG: ConfigType<"swc">;
package/lib/common.js ADDED
@@ -0,0 +1,225 @@
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
+ 'env-flags',
28
+ '@app'
29
+ ];
30
+ let defaultSplitChunk = {
31
+ chunks: 'all',
32
+ minSize: 1024,
33
+ minChunks: 1,
34
+ cacheGroups: {
35
+ route: {
36
+ test: /[\\/].git[\\/]router/,
37
+ priority: -10,
38
+ reuseExistingChunk: true,
39
+ name: 'route'
40
+ },
41
+ example: {
42
+ test: /[\\/].git[\\/]example/,
43
+ priority: -10,
44
+ reuseExistingChunk: true,
45
+ name: 'example'
46
+ }
47
+ }
48
+ };
49
+ if (APPTYPE === 'single-component') {
50
+ defaultSplitChunk = false;
51
+ }
52
+ const defaultConfig = {
53
+ seo: false,
54
+ mode: 'csr',
55
+ compiler: 'swc',
56
+ bundleAnalyzer: {
57
+ analyzerMode: 'static',
58
+ reportFilename: 'report.html',
59
+ openAnalyzer: false
60
+ },
61
+ entry: {},
62
+ minifier: {
63
+ js: {},
64
+ css: {}
65
+ },
66
+ sourceMap: {
67
+ filename: '[file].map',
68
+ publicPath: ''
69
+ },
70
+ env: {},
71
+ routeBaseName: '/',
72
+ publicPath: '/',
73
+ designSize: APPTYPE === 'mobile' ? 375 : 1680,
74
+ fallbackCompPath: null,
75
+ modifyVars: {},
76
+ prefixCls: 'n',
77
+ alias: {},
78
+ layoutSider: {},
79
+ moduleRules: [],
80
+ prefixJsLoader: [],
81
+ cssModules: [],
82
+ importOnDemand: {},
83
+ proxy: [],
84
+ cacheDirectory: `${PROGRAMPATH}/node_modules/.temp_cache`,
85
+ devServer: {
86
+ allowedHosts: [
87
+ '.baidu.com'
88
+ ],
89
+ host: 'localhost',
90
+ port: 3000,
91
+ https: false,
92
+ compress: false
93
+ },
94
+ htmlPluginOption: {
95
+ template: `./node_modules/${pkgName}/template/index.html`,
96
+ favicon: `./node_modules/${pkgName}/template/favicon.ico`,
97
+ tags: []
98
+ },
99
+ assetHtml: [],
100
+ routerMode: 'browser',
101
+ fixBrowserRouter: false,
102
+ plugins: [],
103
+ splitChunk: defaultSplitChunk,
104
+ runtimeChunk: APPTYPE === 'single-component' ? false : 'single',
105
+ moduleFederation: [],
106
+ rulesInclude: {
107
+ less: includeModule,
108
+ css: includeModule,
109
+ js: includeModule,
110
+ media: includeModule,
111
+ fonts: includeModule
112
+ },
113
+ mdx: {
114
+ jsxImportSource: jsxImportSource,
115
+ useDynamicImport: true,
116
+ remarkPlugins: [],
117
+ rehypePlugins: []
118
+ },
119
+ jsxDomExpressions: {
120
+ moduleName: 'solid-js/web',
121
+ builtIns: [
122
+ 'For',
123
+ 'Show',
124
+ 'Switch',
125
+ 'Match',
126
+ 'Suspense',
127
+ 'SuspenseList',
128
+ 'Portal',
129
+ 'Index',
130
+ 'Dynamic',
131
+ 'ErrorBoundary'
132
+ ],
133
+ contextToCustomElements: true,
134
+ wrapConditionals: true,
135
+ generate: 'dom',
136
+ hydratable: false
137
+ },
138
+ bar: {
139
+ name: '编译中',
140
+ color: '#6f42c1'
141
+ }
142
+ };
143
+ export const log = (msg)=>{
144
+ readline.cursorTo(process.stdout, 0);
145
+ process.stdout.write(msg);
146
+ };
147
+ let customConf = defaultConfig;
148
+ let configPath = null;
149
+ let normalConf = {};
150
+ let envConf = {};
151
+ try {
152
+ configPath = path.join(PROGRAMPATH, './config/index.ts');
153
+ fs.accessSync(configPath, fs.constants.R_OK);
154
+ } catch (error) {
155
+ configPath = null;
156
+ }
157
+ if (configPath) {
158
+ try {
159
+ const conf = (await readConf(configPath, 'index')).default;
160
+ normalConf = isFunction(conf) ? conf(process) : conf;
161
+ } catch (error) {
162
+ process.stdout.write(chalk.red(error));
163
+ }
164
+ }
165
+ if (CUSTOMCONFIG) {
166
+ let customConfigPath = null;
167
+ try {
168
+ customConfigPath = path.join(PROGRAMPATH, `./config/${CUSTOMCONFIG}.ts`);
169
+ fs.accessSync(customConfigPath, fs.constants.R_OK);
170
+ } catch (error) {
171
+ customConfigPath = null;
172
+ }
173
+ if (customConfigPath !== null) {
174
+ try {
175
+ const conf = (await readConf(customConfigPath, CUSTOMCONFIG)).default;
176
+ envConf = isFunction(conf) ? conf(process) : conf;
177
+ } catch (error) {
178
+ process.stdout.write(chalk.red(error));
179
+ }
180
+ }
181
+ }
182
+ customConf = merge(customConf, normalConf, envConf);
183
+ if (customConf.compiler === 'tsc' && customConf.minifier) {
184
+ if (!customConf.minifier.js) {
185
+ Object.assign(customConf.minifier, {
186
+ js: {
187
+ type: 'terser'
188
+ }
189
+ });
190
+ }
191
+ if (!customConf.minifier.css) {
192
+ Object.assign(customConf.minifier, {
193
+ css: {
194
+ type: 'cssnano'
195
+ }
196
+ });
197
+ }
198
+ }
199
+ if (customConf.devtool === false) customConf.sourceMap = false;
200
+ if (customConf.sourceMap === false) customConf.devtool = false;
201
+ if (customConf.fixBrowserRouter && customConf.htmlPluginOption) {
202
+ if (!customConf.htmlPluginOption.tags) {
203
+ customConf.htmlPluginOption.tags = [];
204
+ }
205
+ customConf.htmlPluginOption.tags.push({
206
+ textContent: `
207
+ (function(l) {
208
+ if (l.search[1] === '/' ) {
209
+ var decoded = l.search.slice(1).split('&').map(function(s) {
210
+ return s.replace(/~and~/g, '&')
211
+ }).join('?');
212
+ window.history.replaceState(null, null,
213
+ l.pathname.slice(0, -1) + decoded + l.hash
214
+ );
215
+ }
216
+ }(window.location))
217
+ `
218
+ });
219
+ }
220
+ export const CONFIG = customConf;
221
+ export const PUBLICPATH = CONFIG.publicPath || '/';
222
+ global.NEKOCLICONFIG = {
223
+ CONFIG,
224
+ log
225
+ };
@@ -1,2 +1,2 @@
1
- import type { CoverageType, ProjectCoverageType } from '../typings/global.d.ts';
1
+ import type { CoverageType, ProjectCoverageType } from '../typings/global.js';
2
2
  export declare const coverage: Record<string, CoverageType & Partial<ProjectCoverageType>>;
@@ -0,0 +1,30 @@
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) {}
@@ -0,0 +1,6 @@
1
+ declare const define: {
2
+ 'process.env': {
3
+ NODE_ENV: string | undefined;
4
+ };
5
+ };
6
+ export default define;
package/lib/define.js ADDED
@@ -0,0 +1,9 @@
1
+ import { CONFIG } from './common.js';
2
+ import { NODE_ENV } from './process-env.js';
3
+ const define = {
4
+ 'process.env': {
5
+ NODE_ENV: NODE_ENV,
6
+ ...CONFIG.env
7
+ }
8
+ };
9
+ export default define;
package/lib/docs.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const envApi: Record<string, string>;
package/lib/docs.js ADDED
@@ -0,0 +1,118 @@
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/md';
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
+ }
@@ -1,3 +1,4 @@
1
+ import { type Compiler } from 'webpack';
1
2
  declare class DoneWebpackPlugin {
2
3
  options: {
3
4
  done?: () => void;
@@ -5,12 +6,6 @@ declare class DoneWebpackPlugin {
5
6
  constructor(options: {
6
7
  done?: () => void;
7
8
  });
8
- apply(compiler: {
9
- hooks: {
10
- done: {
11
- tap: (arg0: string, arg1: () => void) => void;
12
- };
13
- };
14
- }): void;
9
+ apply(compiler: Compiler): void;
15
10
  }
16
11
  export default DoneWebpackPlugin;
package/lib/done.js ADDED
@@ -0,0 +1,12 @@
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.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function esm(templateStrings: TemplateStringsArray, ...substitutions: unknown[]): string;
package/lib/esm.js ADDED
@@ -0,0 +1,7 @@
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
+ }
@@ -0,0 +1 @@
1
+ export default function generateApi(path: string): string;