sugar-scripts 0.2.0-beta.0 → 1.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 (90) hide show
  1. package/lib/bin/cli-ts.d.ts +1 -0
  2. package/lib/bin/cli-ts.js +4 -0
  3. package/lib/bin/cli-ts.js.map +1 -0
  4. package/lib/bin/cli.d.ts +1 -0
  5. package/lib/bin/cli.js +4 -0
  6. package/lib/bin/cli.js.map +1 -0
  7. package/lib/commander/index.d.ts +1 -0
  8. package/lib/commander/index.js +79 -0
  9. package/lib/commander/index.js.map +1 -0
  10. package/lib/constants/index.d.ts +4 -0
  11. package/lib/constants/index.js +8 -0
  12. package/lib/constants/index.js.map +1 -0
  13. package/lib/core/build.d.ts +2 -0
  14. package/lib/core/build.js +74 -0
  15. package/lib/core/build.js.map +1 -0
  16. package/lib/core/cache.d.ts +2 -0
  17. package/lib/core/cache.js +9 -0
  18. package/lib/core/cache.js.map +1 -0
  19. package/lib/core/info.d.ts +1 -0
  20. package/lib/core/info.js +6 -0
  21. package/lib/core/info.js.map +1 -0
  22. package/lib/core/init-running-context.d.ts +2 -0
  23. package/lib/core/init-running-context.js +30 -0
  24. package/lib/core/init-running-context.js.map +1 -0
  25. package/lib/core/run-application.d.ts +2 -0
  26. package/lib/core/run-application.js +9 -0
  27. package/lib/core/run-application.js.map +1 -0
  28. package/lib/core/running-context.d.ts +23 -0
  29. package/lib/core/running-context.js +52 -0
  30. package/lib/core/running-context.js.map +1 -0
  31. package/lib/custom-config.type.d.ts +51 -0
  32. package/lib/custom-config.type.js +8 -0
  33. package/lib/custom-config.type.js.map +1 -0
  34. package/lib/index.d.ts +1 -0
  35. package/lib/index.js +6 -0
  36. package/lib/index.js.map +1 -0
  37. package/lib/shared/file-helpers.d.ts +18 -0
  38. package/lib/shared/file-helpers.js +227 -0
  39. package/lib/shared/file-helpers.js.map +1 -0
  40. package/lib/webpack/dll-dependencies-manifest-plugin.d.ts +15 -0
  41. package/lib/webpack/dll-dependencies-manifest-plugin.js +79 -0
  42. package/lib/webpack/dll-dependencies-manifest-plugin.js.map +1 -0
  43. package/lib/webpack/load-manifest.d.ts +11 -0
  44. package/lib/webpack/load-manifest.js +47 -0
  45. package/lib/webpack/load-manifest.js.map +1 -0
  46. package/lib/webpack/run-webpack.d.ts +2 -0
  47. package/lib/webpack/run-webpack.js +23 -0
  48. package/lib/webpack/run-webpack.js.map +1 -0
  49. package/lib/webpack/server-browser-entry.d.ts +12 -0
  50. package/lib/webpack/server-browser-entry.js +41 -0
  51. package/lib/webpack/server-browser-entry.js.map +1 -0
  52. package/lib/webpack/webpack.browser.d.ts +4 -0
  53. package/lib/webpack/webpack.browser.js +88 -0
  54. package/lib/webpack/webpack.browser.js.map +1 -0
  55. package/lib/webpack/webpack.common.d.ts +7 -0
  56. package/lib/webpack/webpack.common.js +80 -0
  57. package/lib/webpack/webpack.common.js.map +1 -0
  58. package/lib/webpack/webpack.server.d.ts +4 -0
  59. package/lib/webpack/webpack.server.js +74 -0
  60. package/lib/webpack/webpack.server.js.map +1 -0
  61. package/package.json +17 -32
  62. package/src/bin/cli-ts.ts +3 -0
  63. package/src/index.ts +0 -3
  64. package/CHANGELOG.md +0 -26
  65. package/bin/cli-ts.js +0 -3
  66. package/bin/cli.js +0 -3
  67. package/src/app-utils/index.ts +0 -1
  68. package/src/app-utils/static.ts +0 -42
  69. package/src/commander/index.ts +0 -95
  70. package/src/configs/babel.server.config.ts +0 -42
  71. package/src/configs/babel.static.config.ts +0 -43
  72. package/src/constants/index.ts +0 -5
  73. package/src/core/build.ts +0 -98
  74. package/src/core/cache.ts +0 -15
  75. package/src/core/entry.ts +0 -189
  76. package/src/core/info.ts +0 -5
  77. package/src/core/init-running-context.ts +0 -27
  78. package/src/core/run-application.ts +0 -12
  79. package/src/core/running-context.ts +0 -92
  80. package/src/custom-config.type.ts +0 -66
  81. package/src/shared/file-helpers.ts +0 -192
  82. package/src/typings.d.ts +0 -8
  83. package/src/webpack/auto-entries.ts +0 -5
  84. package/src/webpack/dll-dependencies-manifest-plugin.ts +0 -115
  85. package/src/webpack/load-manifest.ts +0 -73
  86. package/src/webpack/run-webpack.ts +0 -22
  87. package/src/webpack/webpack.browser.ts +0 -107
  88. package/src/webpack/webpack.common.ts +0 -146
  89. package/src/webpack/webpack.server.ts +0 -100
  90. package/tsconfig.json +0 -25
package/src/core/entry.ts DELETED
@@ -1,189 +0,0 @@
1
- import path from 'path';
2
- import {
3
- Application,
4
- Controller,
5
- ControllerContext
6
- } from 'sugar-server';
7
-
8
- import {
9
- CustomRender
10
- } from '../custom-config.type';
11
-
12
- export const ENTRIES_KEY = Symbol('_sugar_entries');
13
- export const ENTRIES_CONFIG_KEY = Symbol('_sugar_entries_config');
14
-
15
- export interface EntryConfig {
16
- filePath: string
17
- }
18
-
19
- export interface EntriesController extends Controller {
20
- [ENTRIES_KEY]: EntryConfig[]
21
- }
22
-
23
- const defaultRender: CustomRender = (
24
- ctx,
25
- entries,
26
- custom
27
- ) => {
28
- return entries.toString();
29
- }
30
-
31
- const render: CustomRender = (
32
- ...args
33
- ) => {
34
- let currentRender = defaultRender;
35
- console.log('SUGAR_PROJECT_RENDER', process.env.SUGAR_PROJECT_RENDER)
36
- if (process.env.SUGAR_PROJECT_RENDER) {
37
- try {
38
- currentRender = require(process.env.SUGAR_PROJECT_RENDER).default;
39
- console.log('load custom render success');
40
- } catch (e) {}
41
- }
42
- return currentRender(
43
- ...args
44
- )
45
- }
46
-
47
- // discuss:需要string[] 吗?
48
- export type RegisterFilePath = string | {[key: string]: string}
49
-
50
- export function register (
51
- filePath: RegisterFilePath
52
- ) {
53
- return function (
54
- target: Controller,
55
- key: string,
56
- descriptor: PropertyDescriptor
57
- ) {
58
- if (!Object.getOwnPropertyDescriptor(target, ENTRIES_KEY)) {
59
- Object.defineProperty(target, ENTRIES_KEY, {
60
- configurable: true,
61
- enumerable: false,
62
- writable: true,
63
- value: []
64
- })
65
- }
66
-
67
- if (typeof filePath === 'string') {
68
- (target as EntriesController)[ENTRIES_KEY].push({
69
- filePath
70
- })
71
- } else {
72
- Object.keys(filePath).forEach((filePathKey) => {
73
- const oneFilePath = filePath[filePathKey];
74
- (target as EntriesController)[ENTRIES_KEY].push({
75
- filePath: oneFilePath
76
- })
77
- })
78
- }
79
-
80
- const oldValue = descriptor.value;
81
- descriptor.value = async function (
82
- ctx: ControllerContext,
83
- ...args: any
84
- ) {
85
- // ctx.app
86
- let oldResult;
87
- if (oldValue) {
88
- oldResult = await oldValue.call(this, ...args);
89
- }
90
-
91
- let envEntries = ENV_ENTRIES;
92
- if (
93
- (ctx.app.constructor as any).ENTRIES
94
- ) {
95
- envEntries = (ctx.app.constructor as any).ENTRIES;
96
- }
97
- console.log('envEntries', envEntries, ENV_ENTRIES )
98
-
99
- let entries: string[] | {[key: string]: string[]} = [];
100
- if (typeof filePath === 'string') {
101
- entries = envEntries[filePath] || [];
102
- } else {
103
- entries = Object.keys(filePath).reduce((
104
- currentEntries,
105
- filePathKey
106
- ) => {
107
- const oneFilePath = filePath[filePathKey];
108
- currentEntries[filePathKey] = envEntries[oneFilePath];
109
- return currentEntries;
110
- }, {} as {[key: string]: string[]})
111
- }
112
-
113
- console.log(
114
- 'will search file',
115
- envEntries,
116
- filePath,
117
- entries
118
- )
119
-
120
- return render(
121
- ctx,
122
- entries,
123
- oldResult
124
- );
125
- }
126
- }
127
- }
128
-
129
- export const ENTRY_WEBPACK_INJECT_KEY = 'ENTRY_WEBPACK_INJECT_KEY';
130
-
131
- export const ENV_ENTRIES = (process.env.SUGAR_PROJECT_ENTRIES || {}) as {
132
- [entryKey: string]: string[]
133
- };
134
-
135
- export function getEntryUrl (
136
- filePath: string
137
- ) {
138
- return '';
139
- }
140
-
141
- export function getEntries (
142
- dirname: string
143
- ) {
144
- let entries = {};
145
-
146
- require(
147
- path.resolve(
148
- dirname,
149
- ''
150
- )
151
- )
152
- }
153
-
154
- export function getEntriesFromController (
155
- controller: Controller
156
- ) {
157
- return (controller as EntriesController)[ENTRIES_KEY] || [];
158
- }
159
-
160
- export function getEntriesFromControllers (
161
- controllers: Controller[],
162
- root: string
163
- ) {
164
- const entries: {
165
- [key: string]: string
166
- } = {};
167
- controllers.forEach(
168
- (controller) => {
169
- getEntriesFromController(controller).forEach(({ filePath }) => {
170
- entries[filePath] = path.resolve(
171
- root,
172
- filePath
173
- )
174
- })
175
- }
176
- )
177
- return entries;
178
- }
179
-
180
- export function getEntriesFromApplicationClass (
181
- ApplicationClass: typeof Application,
182
- root: string
183
- ) {
184
- const app = new ApplicationClass();
185
- return getEntriesFromControllers(
186
- app.controllers,
187
- root
188
- )
189
- }
package/src/core/info.ts DELETED
@@ -1,5 +0,0 @@
1
- import {
2
- router
3
- } from 'sugar-server';
4
-
5
- export const info = () => {}
@@ -1,27 +0,0 @@
1
- import {
2
- findProject,
3
- findPackage
4
- } from '../shared/file-helpers';
5
-
6
- import {
7
- SugarScriptsContext
8
- } from './running-context';
9
-
10
- export const initRunningContext = async (dir: string) => {
11
- const {
12
- root,
13
- packageJson,
14
- packageConfig
15
- } = await findPackage(dir);
16
- const { projectRoot, projectConfig } = await findProject(root);
17
- if (!packageConfig || !projectConfig) {
18
- throw new Error('')
19
- }
20
- return new SugarScriptsContext({
21
- root,
22
- packageName: packageJson.name,
23
- packageConfig,
24
- projectRoot,
25
- projectConfig
26
- })
27
- }
@@ -1,12 +0,0 @@
1
- import {
2
- Application
3
- } from 'sugar-server';
4
-
5
- export const runApplication = (
6
- ApplicationClass: typeof Application,
7
- port: number
8
- ) => {
9
- const app = new ApplicationClass();
10
-
11
- app.listen(port)
12
- }
@@ -1,92 +0,0 @@
1
- import { createHash } from 'crypto';
2
- import path from 'path';
3
-
4
- type BuildEntry = { [key: string]: string|string[] };
5
-
6
- interface PackageConfig {
7
- browser?: {
8
- /**
9
- * 是否构建dll用的输出
10
- */
11
- dll?: boolean;
12
- /**
13
- * 输出目录
14
- */
15
- output: string;
16
- /**
17
- * controller/index
18
- */
19
- input?: string;
20
- entry?: BuildEntry
21
- };
22
-
23
- server?: {
24
- dll?: boolean;
25
- output: string;
26
- entry: string;
27
- render?: string;
28
- };
29
- }
30
-
31
- interface ProjectConfig {
32
- cacheDir: string;
33
- }
34
-
35
- export function getHashFromRoot (
36
- root: string
37
- ) {
38
- const hash = createHash('md5');
39
- hash.update(root);
40
- return `s_${hash.digest('hex')}`;
41
- }
42
-
43
- export class SugarScriptsContext {
44
- root: string;
45
- rootHash: string;
46
- packageName: string;
47
- packageConfig: PackageConfig;
48
- projectRoot: string;
49
- projectConfig: ProjectConfig;
50
-
51
- constructor (
52
- {
53
- root,
54
- packageName,
55
- packageConfig,
56
- projectRoot,
57
- projectConfig
58
- }: {
59
- root: string;
60
- packageName: string;
61
- packageConfig: PackageConfig;
62
- projectRoot: string;
63
- projectConfig: ProjectConfig;
64
- }
65
- ) {
66
- this.root = root;
67
- this.packageName = packageName;
68
- this.packageConfig = packageConfig;
69
- this.projectRoot = projectRoot;
70
- this.projectConfig = projectConfig;
71
- this.rootHash = getHashFromRoot(root);
72
- }
73
-
74
- serverEntryName = 'main';
75
-
76
- getStartFilePath () {
77
- if (this.packageConfig.server) {
78
- return path.resolve(
79
- this.root,
80
- this.packageConfig.server.output,
81
- this.serverEntryName
82
- )
83
- }
84
- }
85
-
86
- getCacheDir () {
87
- return path.resolve(
88
- this.projectRoot,
89
- this.projectConfig.cacheDir
90
- )
91
- }
92
- }
@@ -1,66 +0,0 @@
1
- import type {
2
- ControllerContext
3
- } from 'sugar-server';
4
- import type WebpackChainConfig from 'webpack-chain';
5
-
6
- import {
7
- SugarScriptsContext
8
- } from './core/running-context'
9
-
10
- export namespace SugarScriptsProject {
11
- export type BrowserWebpackConfig = CustomWebpackConfig;
12
-
13
- export type ServerWebpackConfig = CustomWebpackConfig;
14
-
15
- export interface PackageConfig {
16
- browser?: {
17
- /**
18
- * 是否构建dll用的输出
19
- */
20
- dll?: boolean;
21
- /**
22
- * 输出目录
23
- */
24
- output: string;
25
- /**
26
- * controller/index
27
- */
28
- input?: string;
29
- entry?: BuildEntry
30
- };
31
-
32
- server?: {
33
- dll?: boolean;
34
- output: string;
35
- entry: string;
36
- render?: string;
37
- };
38
- }
39
-
40
- export interface ProjectConfig {
41
- cacheDir: string;
42
- }
43
-
44
-
45
- export interface CustomRender<C = any> {
46
- (
47
- ctx: ControllerContext,
48
- entries: string[] | {[key: string]: string[]},
49
- custom: C
50
- ): string
51
- };
52
- }
53
-
54
- type BuildEntry = { [key: string]: string|string[] };
55
-
56
- export type CustomWebpackConfig = (
57
- webpackChainConfig: WebpackChainConfig,
58
- context: SugarScriptsContext
59
- ) => void;
60
-
61
- export type CustomRender<C = any> = (
62
- ctx: ControllerContext,
63
- entries: string[] | {[key: string]: string[]},
64
- custom: C
65
- ) => string;
66
-
@@ -1,192 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
-
4
- import {
5
- SUGAR_PACKAGE_CONFIG_FILENAME,
6
- SUGAR_PROJECT_CONFIG_FILENAME
7
- } from '../constants';
8
- import {
9
- SugarScriptsProject
10
- } from '../custom-config.type';
11
- // nodejs v10 支持
12
- // nodejs v14 才开始支持require('fs/promises')
13
- const fsPromises = fs.promises;
14
-
15
- export const searchFiles = async (
16
- dir: string,
17
- fileCheck: string | ((filePath: string) => boolean),
18
- exclude?: string
19
- ) => {
20
- try {
21
- await fsPromises.access(dir)
22
- } catch (e) {
23
- return [];
24
- }
25
- const files = await fsPromises.readdir(dir);
26
- let currentFiles: string[] = [];
27
-
28
- await Promise.all(
29
- files.map(async (filename) => {
30
- if (exclude === filename) return;
31
- const fileOrDir = path.join(dir, filename);
32
- const stats = await fsPromises.stat(fileOrDir);
33
- if (stats.isFile()) {
34
- if (typeof fileCheck === 'string') {
35
- if (filename === fileCheck) {
36
- currentFiles.push(fileOrDir)
37
- }
38
- } else if (fileCheck(fileOrDir)) {
39
- currentFiles.push(fileOrDir)
40
- }
41
- } else if (stats.isDirectory()) {
42
- const childCurrentFiles = await searchFiles(fileOrDir, fileCheck);
43
- currentFiles = currentFiles.concat(childCurrentFiles);
44
- }
45
- })
46
- )
47
- return currentFiles;
48
- }
49
-
50
- export const findSiblingFile = async (
51
- currentFilePath: string,
52
- searchFileName: string
53
- ) => {
54
- const dir = path.dirname(currentFilePath);
55
- const searchFilePath = path.join(dir, searchFileName);
56
-
57
- const searchFileStat = await fsPromises.stat(searchFilePath);
58
- if (searchFileStat.isFile()) {
59
- return searchFilePath;
60
- }
61
-
62
- return null;
63
- }
64
-
65
- export const findParentFile = async (
66
- currentFilePath: string,
67
- searchFileName: string
68
- ) => {
69
- const dir = path.resolve(
70
- path.dirname(currentFilePath),
71
- '../'
72
- );
73
- const searchFilePath = path.join(dir, searchFileName);
74
-
75
- const searchFileStat = await fsPromises.stat(searchFilePath);
76
- if (searchFileStat.isFile()) {
77
- return searchFilePath;
78
- }
79
-
80
- return null;
81
- }
82
-
83
- export const loadJSON = async (filePath: string) => {
84
- try {
85
- const contentBuffer = await fsPromises.readFile(filePath);
86
- const content = contentBuffer.toString();
87
-
88
- return JSON.parse(content);
89
- } catch (e) {
90
- return {};
91
- }
92
- }
93
-
94
- export const writeFileSync = (
95
- filePath: string,
96
- data: string | NodeJS.ArrayBufferView
97
- ) => {
98
- const dir = path.dirname(filePath);
99
- fs.mkdirSync(dir, { recursive: true })
100
- fs.writeFileSync(
101
- filePath,
102
- data
103
- )
104
- }
105
-
106
- export const findPackage = async (dir: string): Promise<{
107
- root: string;
108
- packageJson: any;
109
- packageConfig: SugarScriptsProject.PackageConfig | null;
110
- }> => {
111
- const packagePath = path.resolve(dir, 'package.json');
112
-
113
- let existed = true;
114
- try {
115
- await fsPromises.access(packagePath, fs.constants.F_OK);
116
- } catch (e) {
117
- existed = false;
118
- }
119
-
120
- let packageConfig = null;
121
- try {
122
- packageConfig = require(
123
- path.resolve(dir, SUGAR_PACKAGE_CONFIG_FILENAME)
124
- ).packageConfig;
125
- } catch (e) {}
126
-
127
- if (existed) {
128
- return {
129
- root: dir,
130
- packageJson: require(
131
- packagePath
132
- ),
133
- packageConfig
134
- };
135
- }
136
-
137
- if (dir === '/') {
138
- throw new Error('not found package.json');
139
- }
140
-
141
- return findPackage(
142
- path.resolve(dir, '../')
143
- )
144
- }
145
-
146
- export const findProject = async (dir: string): Promise<{
147
- projectRoot: string,
148
- projectConfig: SugarScriptsProject.ProjectConfig
149
- }> => {
150
- const projectPath = path.resolve(dir, SUGAR_PROJECT_CONFIG_FILENAME);
151
-
152
- let projectConfig = null;
153
- try {
154
- projectConfig = require(projectPath).projectConfig;
155
- } catch (e) {}
156
-
157
- if (dir === '/') {
158
- throw new Error('not found sugar.project');
159
- }
160
-
161
- if (projectConfig) {
162
- return {
163
- projectRoot: dir,
164
- projectConfig
165
- };
166
- }
167
-
168
- return findProject(
169
- path.resolve(dir, '../')
170
- )
171
- }
172
-
173
- export const rm = async (filePath: string) => {
174
- const stat = await fsPromises.stat(filePath);
175
- if (
176
- stat.isFile()
177
- || stat.isSymbolicLink()
178
- ) {
179
- await fsPromises.unlink(filePath);
180
- return;
181
- }
182
- if (stat.isDirectory()) {
183
- const childFilePaths = await fsPromises.readdir(filePath);
184
- await Promise.all(
185
- childFilePaths.map((childFilePath) => (
186
- rm(path.resolve(filePath, childFilePath))
187
- ))
188
- );
189
- await fsPromises.rmdir(filePath);
190
- return;
191
- }
192
- }
package/src/typings.d.ts DELETED
@@ -1,8 +0,0 @@
1
- declare module 'babel-loader' {}
2
-
3
- declare module 'webpack-manifest-plugin' {
4
- export class WebpackManifestPlugin {
5
- constructor (options: any);
6
- apply: any
7
- }
8
- }
@@ -1,5 +0,0 @@
1
- var a = require(process.env.SUGAR_PROJECT_REAL_ENTRY || '');
2
-
3
- a.default.ENTRIES = process.env.SUGAR_PROJECT_ENTRIES;
4
-
5
- export default a.default;
@@ -1,115 +0,0 @@
1
- import webpack from 'webpack';
2
-
3
- import {
4
- writeFileSync
5
- } from '../shared/file-helpers';
6
-
7
- export interface DllDependenciesManifestPluginOptions {
8
- dllAssets: {
9
- [dllName: string]: string[];
10
- }
11
- fileName: string,
12
- generate: (entries: {
13
- [entry: string]: string[]
14
- }) => any
15
- }
16
-
17
- const PLUGIN_NAME = 'DllDependenciesManifestPlugin';
18
-
19
- export class DllDependenciesManifestPlugin {
20
- options: DllDependenciesManifestPluginOptions;
21
- constructor (options: DllDependenciesManifestPluginOptions) {
22
- this.options = options;
23
- }
24
-
25
- apply (compiler: webpack.Compiler) {
26
- const logger = compiler.getInfrastructureLogger(PLUGIN_NAME);
27
-
28
- compiler.hooks.done.tap(
29
- PLUGIN_NAME,
30
- (stats) => {
31
- var data = stats.toJson({
32
- all: false,
33
- entrypoints: true,
34
- chunks: true,
35
- chunkModules: true,
36
- // nestedModules: true,
37
- dependentModules: true,
38
- moduleAssets: true,
39
- assets: true,
40
- modules: true,
41
- // moduleTrace: true,
42
- // reasons: true,
43
- chunkRelations: true,
44
- ids: true,
45
- publicPath: true
46
- })
47
-
48
- const publicPath = data.publicPath;
49
- const entries: {
50
- [entry: string]: string[]
51
- } = data.entrypoints
52
- ? Object.keys(data.entrypoints).reduce((entries, entryKey) => {
53
- entries[entryKey] = [];
54
- const entryAssets = data.entrypoints![entryKey].assets;
55
- if (entryAssets) {
56
- const normalizePath = (path: string): string => {
57
- if (!path.endsWith('/')) {
58
- return `${path}/`;
59
- }
60
-
61
- return path;
62
- };
63
-
64
- entries[entryKey] = entries[entryKey].concat(
65
- entryAssets.map(({ name }) => (
66
- publicPath ? normalizePath(publicPath) + name : name
67
- ))
68
- )
69
- };
70
- return entries;
71
- }, {} as {
72
- [entry: string]: string[]
73
- })
74
- : {};
75
-
76
- data.chunks?.forEach((chunk) => {
77
- if (chunk.entry) {
78
- let depDllAssets: string[] = [];
79
- chunk.modules?.forEach((module) => {
80
- if (
81
- module.type !== 'module'
82
- || !module.identifier
83
- ) {
84
- return;
85
- }
86
- const dllNameResult = /dll-reference (.+)$/.exec(module.identifier)
87
- if (!dllNameResult) {
88
- return;
89
- }
90
- const dllName = dllNameResult[1];
91
- depDllAssets = depDllAssets.concat(
92
- this.options.dllAssets[dllName]
93
- )
94
- })
95
- if (entries[chunk.id as any]) {
96
- entries[chunk.id as any] = depDllAssets.concat(entries[chunk.id as any])
97
- }
98
- }
99
- })
100
-
101
- // 去重复
102
- Object.keys(entries).forEach((key) => {
103
- entries[key] = Array.from(new Set(entries[key]))
104
- })
105
-
106
- const manifest = this.options.generate(entries);
107
-
108
- writeFileSync(
109
- this.options.fileName,
110
- JSON.stringify(manifest, null, 2)
111
- )
112
- }
113
- )
114
- }
115
- }