@shijiu/jsview 2.3.151-test.0 → 3.0.0-next-vue.0

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 (78) hide show
  1. package/dom/bin/jsview-dom-browser-engine-core.min.js +1 -1
  2. package/dom/bin/jsview-dom-browser-engine-modules.min.js +1 -1
  3. package/dom/bin/{jsview-dom-browser-forge.1493.9a36.wasm → jsview-dom-browser-forge.1760.0e35.wasm} +0 -0
  4. package/dom/bin/jsview-dom-browser-forge.min.js +1 -1
  5. package/dom/bin/jsview-dom-browser-forge.worker.min.js +1 -1
  6. package/dom/bin/jsview-dom-browser.min.js +1 -1
  7. package/dom/bin/jsview-dom-native.min.js +1 -1
  8. package/dom/bin/jsview-engine-js-native.min.js +1 -1
  9. package/dom/target_core_revision.mjs +2 -2
  10. package/loader/jsv-core-api/jsview-core-api-glue.js +10 -1
  11. package/loader/jsv-core-api/wasm/core-api.js +87 -2
  12. package/loader/jsv-core-api/wasm/wasm-extension.js +5 -0
  13. package/loader/jsview-loader.js +7 -0
  14. package/loader/jsview-main.mjs +2 -1
  15. package/loader/jsview.config.default.js +4 -0
  16. package/package.json +7 -5
  17. package/patches/@vitejs+plugin-vue+4.0.0.patch +51 -0
  18. package/patches/@vitejs+plugin-vue+6.0.6.patch +54 -0
  19. package/patches/@vue+compiler-dom+3.2.45.patch +22 -0
  20. package/patches/@vue+compiler-dom+3.6.0-beta.10.patch +22 -0
  21. package/patches/@vue+compiler-sfc+3.2.45.patch +1986 -0
  22. package/patches/@vue+compiler-sfc+3.6.0-beta.10.patch +69 -0
  23. package/patches/@vue+runtime-core+3.2.45.patch +353 -0
  24. package/patches/@vue+runtime-core+3.6.0-beta.10.patch +196 -0
  25. package/patches/@vue+runtime-dom+3.2.45.patch +81 -0
  26. package/patches/@vue+runtime-dom+3.6.0-beta.10.patch +47 -0
  27. package/patches/postcss-js+5.1.0.patch +20 -0
  28. package/patches/vite+4.0.0.patch +117 -0
  29. package/patches/vite+8.0.9.patch +77 -0
  30. package/patches/vue-router+4.1.6.patch +17 -0
  31. package/patches/vue-router+5.0.6.patch +0 -0
  32. package/{patches/node_modules/@vue/compiler-sfc/dist/jsview-css-to-js.js → thirdparty/@vue/compiler-sfc/jsview-css-to-js.cjs} +15 -10
  33. package/{patches/node_modules/@vue/compiler-sfc/dist/jsview-style-checker.js → thirdparty/@vue/compiler-sfc/jsview-style-checker.cjs} +6 -1
  34. package/{patches/node_modules/@vue/compiler-sfc/dist/jsview-style-formator.cjs.js → thirdparty/@vue/compiler-sfc/jsview-style-formator.cjs} +3 -0
  35. package/thirdparty/@vue/runtime-core/jsview-render-break.mjs +189 -0
  36. package/thirdparty/vite/jsview-vite-extension.mjs +336 -0
  37. package/tools/jsview-build-zip.mjs +7 -2
  38. package/tools/jsview-common.mjs +17 -4
  39. package/tools/{jsview-logger.js → jsview-logger.cjs} +1 -1
  40. package/tools/jsview-post-build.mjs +55 -0
  41. package/tools/jsview-post-install.mjs +105 -103
  42. package/tools/jsview-run-tool.mjs +3 -6
  43. package/tools/jsview-vue-devtools.mjs +1 -1
  44. package/loader/jsview-react-main.js +0 -37
  45. package/loader/jsview-react-script-loader.js +0 -134
  46. package/patches/node_modules/@vitejs/plugin-react/dist/index.cjs +0 -520
  47. package/patches/node_modules/@vitejs/plugin-react/package.json +0 -55
  48. package/patches/node_modules/@vitejs/plugin-vue/dist/index.mjs +0 -2756
  49. package/patches/node_modules/@vitejs/plugin-vue/package.json +0 -51
  50. package/patches/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.js +0 -3152
  51. package/patches/node_modules/@vue/compiler-dom/package.json +0 -43
  52. package/patches/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +0 -17730
  53. package/patches/node_modules/@vue/compiler-sfc/package.json +0 -59
  54. package/patches/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js +0 -8154
  55. package/patches/node_modules/@vue/runtime-core/package.json +0 -38
  56. package/patches/node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts +0 -1531
  57. package/patches/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +0 -1740
  58. package/patches/node_modules/@vue/runtime-dom/package.json +0 -42
  59. package/patches/node_modules/postcss-js/objectifier.js +0 -94
  60. package/patches/node_modules/postcss-js/package.json +0 -42
  61. package/patches/node_modules/react-dev-utils/WebpackDevServerUtils.js +0 -450
  62. package/patches/node_modules/react-dev-utils/package.json +0 -88
  63. package/patches/node_modules/react-dom/cjs/react-dom.development.js +0 -29868
  64. package/patches/node_modules/react-dom/cjs/react-dom.production.min.js +0 -323
  65. package/patches/node_modules/react-dom/package.json +0 -62
  66. package/patches/node_modules/react-scripts/config/paths.js +0 -179
  67. package/patches/node_modules/react-scripts/config/webpack.config.js +0 -858
  68. package/patches/node_modules/react-scripts/package.json +0 -108
  69. package/patches/node_modules/vite/dist/node/chunks/dep-ed9cb113.js +0 -63182
  70. package/patches/node_modules/vite/dist/node/constants.js +0 -125
  71. package/patches/node_modules/vite/dist/node/jsview-vite-extension.js +0 -245
  72. package/patches/node_modules/vite/package.json +0 -153
  73. package/patches/node_modules/vue-router/dist/vue-router.mjs +0 -3613
  74. package/patches/node_modules/vue-router/package.json +0 -114
  75. package/patches/node_modules/webpack-dev-server/client/utils/reloadApp.js +0 -76
  76. package/patches/node_modules/webpack-dev-server/client/utils/sendMessage.js +0 -21
  77. package/patches/node_modules/webpack-dev-server/package.json +0 -141
  78. /package/patches/{node_modules/@originjs/vite-plugin-federation/1.3.4/@originjs+vite-plugin-federation+1.3.4.patch → @originjs+vite-plugin-federation+1.3.4.patch} +0 -0
@@ -1,858 +0,0 @@
1
- // @remove-on-eject-begin
2
- /**
3
- * Copyright (c) 2015-present, Facebook, Inc.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
- // @remove-on-eject-end
9
- 'use strict';
10
-
11
- const fs = require('fs');
12
- const path = require('path');
13
- const webpack = require('webpack');
14
- const resolve = require('resolve');
15
- const HtmlWebpackPlugin = require('html-webpack-plugin');
16
- const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
17
- const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin');
18
- const TerserPlugin = require('terser-webpack-plugin');
19
- const MiniCssExtractPlugin = require('mini-css-extract-plugin');
20
- const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
21
- const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
22
- const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
23
- const WorkboxWebpackPlugin = require('workbox-webpack-plugin');
24
- const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
25
- const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent');
26
- const ESLintPlugin = require('eslint-webpack-plugin');
27
- const paths = require('./paths');
28
- const modules = require('./modules');
29
- const getClientEnvironment = require('./env');
30
- const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin');
31
- const ForkTsCheckerWebpackPlugin =
32
- process.env.TSC_COMPILE_ON_ERROR === 'true'
33
- ? require('react-dev-utils/ForkTsCheckerWarningWebpackPlugin')
34
- : require('react-dev-utils/ForkTsCheckerWebpackPlugin');
35
- const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
36
- // @remove-on-eject-begin
37
- const getCacheIdentifier = require('react-dev-utils/getCacheIdentifier');
38
- // @remove-on-eject-end
39
- const createEnvironmentHash = require('./webpack/persistentCache/createEnvironmentHash');
40
-
41
- // Source maps are resource heavy and can cause out of memory issue for large source files.
42
- const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
43
-
44
- const reactRefreshRuntimeEntry = require.resolve('react-refresh/runtime');
45
- const reactRefreshWebpackPluginRuntimeEntry = require.resolve(
46
- '@pmmmwh/react-refresh-webpack-plugin'
47
- );
48
- const babelRuntimeEntry = require.resolve('babel-preset-react-app');
49
- const babelRuntimeEntryHelpers = require.resolve(
50
- '@babel/runtime/helpers/esm/assertThisInitialized',
51
- { paths: [babelRuntimeEntry] }
52
- );
53
- const babelRuntimeRegenerator = require.resolve('@babel/runtime/regenerator', {
54
- paths: [babelRuntimeEntry],
55
- });
56
-
57
- // Some apps do not need the benefits of saving a web request, so not inlining the chunk
58
- // makes for a smoother build process.
59
- const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK !== 'false';
60
-
61
- const emitErrorsAsWarnings = process.env.ESLINT_NO_DEV_ERRORS === 'true';
62
- const disableESLintPlugin = process.env.DISABLE_ESLINT_PLUGIN === 'true';
63
-
64
- const imageInlineSizeLimit = parseInt(
65
- // JsView Modified >>>
66
- // 资源文件不使用base64
67
- // process.env.IMAGE_INLINE_SIZE_LIMIT || '10000'
68
- process.env.IMAGE_INLINE_SIZE_LIMIT || '0'
69
- // JsView Modified <<<
70
- );
71
-
72
- // Check if TypeScript is setup
73
- const useTypeScript = fs.existsSync(paths.appTsConfig);
74
-
75
- // Check if Tailwind config exists
76
- const useTailwind = fs.existsSync(
77
- path.join(paths.appPath, 'tailwind.config.js')
78
- );
79
-
80
- // Get the path to the uncompiled service worker (if it exists).
81
- const swSrc = paths.swSrc;
82
-
83
- // style files regexes
84
- const cssRegex = /\.css$/;
85
- const cssModuleRegex = /\.module\.css$/;
86
- const sassRegex = /\.(scss|sass)$/;
87
- const sassModuleRegex = /\.module\.(scss|sass)$/;
88
-
89
- const hasJsxRuntime = (() => {
90
- if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
91
- return false;
92
- }
93
-
94
- try {
95
- require.resolve('react/jsx-runtime');
96
- return true;
97
- } catch (e) {
98
- return false;
99
- }
100
- })();
101
-
102
- // This is the production and development configuration.
103
- // It is focused on developer experience, fast rebuilds, and a minimal bundle.
104
- module.exports = function (webpackEnv) {
105
- const isEnvDevelopment = webpackEnv === 'development';
106
- const isEnvProduction = webpackEnv === 'production';
107
-
108
- // Variable used for enabling profiling in Production
109
- // passed into alias object. Uses a flag if passed into the build command
110
- const isEnvProductionProfile =
111
- isEnvProduction && process.argv.includes('--profile');
112
-
113
- // We will provide `paths.publicUrlOrPath` to our app
114
- // as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
115
- // Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
116
- // Get environment variables to inject into our app.
117
- const env = getClientEnvironment(paths.publicUrlOrPath.slice(0, -1));
118
-
119
- const shouldUseReactRefresh = env.raw.FAST_REFRESH;
120
-
121
- // common function to get style loaders
122
- const getStyleLoaders = (cssOptions, preProcessor) => {
123
- const loaders = [
124
- // JsView Modified >>>
125
- // 盒子不支持加载css文件,去掉 build 后的css文件,直接集成到js中。
126
- // isEnvDevelopment && require.resolve('style-loader'),
127
- // isEnvProduction && {
128
- require.resolve('style-loader'),
129
- false && {
130
- // JsView Modified <<<
131
- loader: MiniCssExtractPlugin.loader,
132
- // css is located in `static/css`, use '../../' to locate index.html folder
133
- // in production `paths.publicUrlOrPath` can be a relative path
134
- options: paths.publicUrlOrPath.startsWith('.')
135
- ? { publicPath: '../../' }
136
- : {},
137
- },
138
- {
139
- loader: require.resolve('css-loader'),
140
- options: cssOptions,
141
- },
142
- {
143
- // Options for PostCSS as we reference these options twice
144
- // Adds vendor prefixing based on your specified browser support in
145
- // package.json
146
- loader: require.resolve('postcss-loader'),
147
- options: {
148
- postcssOptions: {
149
- // Necessary for external CSS imports to work
150
- // https://github.com/facebook/create-react-app/issues/2677
151
- ident: 'postcss',
152
- config: false,
153
- plugins: !useTailwind
154
- ? [
155
- 'postcss-flexbugs-fixes',
156
- [
157
- 'postcss-preset-env',
158
- {
159
- autoprefixer: {
160
- flexbox: 'no-2009',
161
- },
162
- stage: 3,
163
- },
164
- ],
165
- // Adds PostCSS Normalize as the reset css with default options,
166
- // so that it honors browserslist config in package.json
167
- // which in turn let's users customize the target behavior as per their needs.
168
- 'postcss-normalize',
169
- ]
170
- : [
171
- 'tailwindcss',
172
- 'postcss-flexbugs-fixes',
173
- [
174
- 'postcss-preset-env',
175
- {
176
- autoprefixer: {
177
- flexbox: 'no-2009',
178
- },
179
- stage: 3,
180
- },
181
- ],
182
- ],
183
- },
184
- sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
185
- },
186
- },
187
- ].filter(Boolean);
188
- if (preProcessor) {
189
- loaders.push(
190
- {
191
- loader: require.resolve('resolve-url-loader'),
192
- options: {
193
- sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
194
- root: paths.appSrc,
195
- },
196
- },
197
- {
198
- loader: require.resolve(preProcessor),
199
- options: {
200
- sourceMap: true,
201
- },
202
- }
203
- );
204
- }
205
- return loaders;
206
- };
207
-
208
- return {
209
- target: ['browserslist'],
210
- // Webpack noise constrained to errors and warnings
211
- stats: 'errors-warnings',
212
- mode: isEnvProduction ? 'production' : isEnvDevelopment && 'development',
213
- // Stop compilation early in production
214
- bail: isEnvProduction,
215
- devtool: isEnvProduction
216
- ? shouldUseSourceMap
217
- ? 'source-map'
218
- : false
219
- : isEnvDevelopment && 'cheap-module-source-map',
220
- // These are the "entry points" to our application.
221
- // This means they will be the "root" imports that are included in JS bundle.
222
- entry: paths.appIndexJs,
223
- output: {
224
- // The build folder.
225
- path: paths.appBuild,
226
- // Add /* filename */ comments to generated require()s in the output.
227
- pathinfo: isEnvDevelopment,
228
- // There will be one main bundle, and one file per asynchronous chunk.
229
- // In development, it does not produce real files.
230
- filename: isEnvProduction
231
- // JsView Modified >>>
232
- // 修改 entry 的文件名
233
- // ? 'static/js/[name].[contenthash:8].js'
234
- // : isEnvDevelopment && 'static/js/bundle.js',
235
- ? 'js/main.jsv.[contenthash:8].js'
236
- : isEnvDevelopment && 'js/main.jsv.js',
237
- // JsView Modified <<<
238
- // There are also additional JS chunk files if you use code splitting.
239
- chunkFilename: isEnvProduction
240
- // JsView Modified >>>
241
- // 修改 chunk 的文件名
242
- // ? 'static/js/[name].[contenthash:8].chunk.js'
243
- // : isEnvDevelopment && 'static/js/[name].chunk.js',
244
- // assetModuleFilename: 'static/media/[name].[hash][ext]',
245
- ? 'js/chunk.jsv.[contenthash:8].js'
246
- : isEnvDevelopment && 'js/[name].chunk.js',
247
- assetModuleFilename: 'media/[name].[hash][ext]',
248
- // JsView Modified <<<
249
- // webpack uses `publicPath` to determine where the app is being served from.
250
- // It requires a trailing slash, or the file assets will get an incorrect path.
251
- // We inferred the "public path" (such as / or /my-project) from homepage.
252
- publicPath: paths.publicUrlOrPath,
253
- // Point sourcemap entries to original disk location (format as URL on Windows)
254
- devtoolModuleFilenameTemplate: isEnvProduction
255
- ? info =>
256
- path
257
- .relative(paths.appSrc, info.absoluteResourcePath)
258
- .replace(/\\/g, '/')
259
- : isEnvDevelopment &&
260
- (info => path.resolve(info.absoluteResourcePath).replace(/\\/g, '/')),
261
- },
262
- cache: {
263
- type: 'filesystem',
264
- version: createEnvironmentHash(env.raw),
265
- cacheDirectory: paths.appWebpackCache,
266
- store: 'pack',
267
- buildDependencies: {
268
- defaultWebpack: ['webpack/lib/'],
269
- config: [__filename],
270
- tsconfig: [paths.appTsConfig, paths.appJsConfig].filter(f =>
271
- fs.existsSync(f)
272
- ),
273
- },
274
- },
275
- infrastructureLogging: {
276
- level: 'none',
277
- },
278
- optimization: {
279
- minimize: isEnvProduction,
280
- minimizer: [
281
- // This is only used in production mode
282
- new TerserPlugin({
283
- terserOptions: {
284
- parse: {
285
- // We want terser to parse ecma 8 code. However, we don't want it
286
- // to apply any minification steps that turns valid ecma 5 code
287
- // into invalid ecma 5 code. This is why the 'compress' and 'output'
288
- // sections only apply transformations that are ecma 5 safe
289
- // https://github.com/facebook/create-react-app/pull/4234
290
- ecma: 8,
291
- },
292
- compress: {
293
- ecma: 5,
294
- warnings: false,
295
- // Disabled because of an issue with Uglify breaking seemingly valid code:
296
- // https://github.com/facebook/create-react-app/issues/2376
297
- // Pending further investigation:
298
- // https://github.com/mishoo/UglifyJS2/issues/2011
299
- comparisons: false,
300
- // Disabled because of an issue with Terser breaking valid code:
301
- // https://github.com/facebook/create-react-app/issues/5250
302
- // Pending further investigation:
303
- // https://github.com/terser-js/terser/issues/120
304
- inline: 2,
305
- },
306
- mangle: {
307
- safari10: true,
308
- },
309
- // Added for profiling in devtools
310
- keep_classnames: isEnvProductionProfile,
311
- keep_fnames: isEnvProductionProfile,
312
- output: {
313
- ecma: 5,
314
- comments: false,
315
- // Turned on because emoji and regex is not minified properly using default
316
- // https://github.com/facebook/create-react-app/issues/2488
317
- ascii_only: true,
318
- },
319
- },
320
- }),
321
- // This is only used in production mode
322
- new CssMinimizerPlugin(),
323
- ],
324
- },
325
- resolve: {
326
- // JsView Added >>>
327
- // 解决JsViewDom的Code Debug中,import(variable)时,npm start报错。
328
- fallback: {
329
- "buffer": false,
330
- "child_process": false,
331
- "os": false,
332
- "path": false,
333
- "stream": false,
334
- "worker_threads": false,
335
- },
336
- // JsView Added <<<
337
-
338
- // This allows you to set a fallback for where webpack should look for modules.
339
- // We placed these paths second because we want `node_modules` to "win"
340
- // if there are any conflicts. This matches Node resolution mechanism.
341
- // https://github.com/facebook/create-react-app/issues/253
342
- modules: ['node_modules', paths.appNodeModules].concat(
343
- modules.additionalModulePaths || []
344
- ),
345
- // These are the reasonable defaults supported by the Node ecosystem.
346
- // We also include JSX as a common component filename extension to support
347
- // some tools, although we do not recommend using it, see:
348
- // https://github.com/facebook/create-react-app/issues/290
349
- // `web` extension prefixes have been added for better support
350
- // for React Native Web.
351
- extensions: paths.moduleFileExtensions
352
- .map(ext => `.${ext}`)
353
- .filter(ext => useTypeScript || !ext.includes('ts')),
354
- alias: {
355
- // Support React Native Web
356
- // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
357
- 'react-native': 'react-native-web',
358
- // Allows for better profiling with ReactDevTools
359
- ...(isEnvProductionProfile && {
360
- 'react-dom$': 'react-dom/profiling',
361
- 'scheduler/tracing': 'scheduler/tracing-profiling',
362
- }),
363
- ...(modules.webpackAliases || {}),
364
-
365
- // JsView Added >>>
366
- // 添加 jsview alias
367
- 'jsview': '@shijiu/jsview-react'
368
- // JsView Added <<<
369
- },
370
- plugins: [
371
- // Prevents users from importing files from outside of src/ (or node_modules/).
372
- // This often causes confusion because we only process files within src/ with babel.
373
- // To fix this, we prevent you from importing files out of src/ -- if you'd like to,
374
- // please link the files into your node_modules/ and let module-resolution kick in.
375
- // Make sure your source files are compiled, as they will not be processed in any way.
376
- new ModuleScopePlugin(paths.appSrc, [
377
- paths.appPackageJson,
378
- reactRefreshRuntimeEntry,
379
- reactRefreshWebpackPluginRuntimeEntry,
380
- babelRuntimeEntry,
381
- babelRuntimeEntryHelpers,
382
- babelRuntimeRegenerator,
383
- ]),
384
- ],
385
- },
386
- module: {
387
- strictExportPresence: true,
388
- rules: [
389
- // Handle node_modules packages that contain sourcemaps
390
- shouldUseSourceMap && {
391
- enforce: 'pre',
392
- exclude: /@babel(?:\/|\\{1,2})runtime/,
393
- test: /\.(js|mjs|jsx|ts|tsx|css)$/,
394
- loader: require.resolve('source-map-loader'),
395
- },
396
- {
397
- // "oneOf" will traverse all following loaders until one will
398
- // match the requirements. When no loader matches it will fall
399
- // back to the "file" loader at the end of the loader list.
400
- oneOf: [
401
- // TODO: Merge this config once `image/avif` is in the mime-db
402
- // https://github.com/jshttp/mime-db
403
- {
404
- test: [/\.avif$/],
405
- type: 'asset',
406
- mimetype: 'image/avif',
407
- parser: {
408
- dataUrlCondition: {
409
- maxSize: imageInlineSizeLimit,
410
- },
411
- },
412
- },
413
- // "url" loader works like "file" loader except that it embeds assets
414
- // smaller than specified limit in bytes as data URLs to avoid requests.
415
- // A missing `test` is equivalent to a match.
416
- {
417
- test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
418
- type: 'asset',
419
- parser: {
420
- dataUrlCondition: {
421
- maxSize: imageInlineSizeLimit,
422
- },
423
- },
424
- },
425
- {
426
- test: /\.svg$/,
427
- use: [
428
- {
429
- loader: require.resolve('@svgr/webpack'),
430
- options: {
431
- prettier: false,
432
- svgo: false,
433
- svgoConfig: {
434
- plugins: [{ removeViewBox: false }],
435
- },
436
- titleProp: true,
437
- ref: true,
438
- },
439
- },
440
- {
441
- loader: require.resolve('file-loader'),
442
- options: {
443
- // JsView Modified >>>
444
- // 修改资源的文件名
445
- // name: 'static/media/[name].[hash].[ext]',
446
- name: 'media/[name].[hash].[ext]',
447
- // JsView Modified <<<
448
- },
449
- },
450
- ],
451
- issuer: {
452
- and: [/\.(ts|tsx|js|jsx|md|mdx)$/],
453
- },
454
- },
455
- // Process application JS with Babel.
456
- // The preset includes JSX, Flow, TypeScript, and some ESnext features.
457
- {
458
- test: /\.(js|mjs|jsx|ts|tsx)$/,
459
- // JsView Modified >>>
460
- // 将jsview和jsviewDebugPath计入打包
461
- // include: paths.appSrc,
462
- include: [ paths.appSrc, paths.jsviewPath, paths.jsviewDebugPath ],
463
- // JsView Modified <<<
464
- loader: require.resolve('babel-loader'),
465
- options: {
466
- customize: require.resolve(
467
- 'babel-preset-react-app/webpack-overrides'
468
- ),
469
- presets: [
470
- [
471
- require.resolve('babel-preset-react-app'),
472
- {
473
- runtime: hasJsxRuntime ? 'automatic' : 'classic',
474
- },
475
- ],
476
- ],
477
- // @remove-on-eject-begin
478
- babelrc: false,
479
- configFile: false,
480
- // Make sure we have a unique cache identifier, erring on the
481
- // side of caution.
482
- // We remove this when the user ejects because the default
483
- // is sane and uses Babel options. Instead of options, we use
484
- // the react-scripts and babel-preset-react-app versions.
485
- cacheIdentifier: getCacheIdentifier(
486
- isEnvProduction
487
- ? 'production'
488
- : isEnvDevelopment && 'development',
489
- [
490
- 'babel-plugin-named-asset-import',
491
- 'babel-preset-react-app',
492
- 'react-dev-utils',
493
- 'react-scripts',
494
- ]
495
- ),
496
- // @remove-on-eject-end
497
- plugins: [
498
- isEnvDevelopment &&
499
- shouldUseReactRefresh &&
500
- require.resolve('react-refresh/babel'),
501
- ].filter(Boolean),
502
- // This is a feature of `babel-loader` for webpack (not Babel itself).
503
- // It enables caching results in ./node_modules/.cache/babel-loader/
504
- // directory for faster rebuilds.
505
- cacheDirectory: true,
506
- // See #6846 for context on why cacheCompression is disabled
507
- cacheCompression: false,
508
- compact: isEnvProduction,
509
- },
510
- },
511
- // Process any JS outside of the app with Babel.
512
- // Unlike the application JS, we only compile the standard ES features.
513
- {
514
- test: /\.(js|mjs)$/,
515
- exclude: /@babel(?:\/|\\{1,2})runtime/,
516
- loader: require.resolve('babel-loader'),
517
- options: {
518
- babelrc: false,
519
- configFile: false,
520
- compact: false,
521
- presets: [
522
- [
523
- require.resolve('babel-preset-react-app/dependencies'),
524
- { helpers: true },
525
- ],
526
- ],
527
- cacheDirectory: true,
528
- // See #6846 for context on why cacheCompression is disabled
529
- cacheCompression: false,
530
- // @remove-on-eject-begin
531
- cacheIdentifier: getCacheIdentifier(
532
- isEnvProduction
533
- ? 'production'
534
- : isEnvDevelopment && 'development',
535
- [
536
- 'babel-plugin-named-asset-import',
537
- 'babel-preset-react-app',
538
- 'react-dev-utils',
539
- 'react-scripts',
540
- ]
541
- ),
542
- // @remove-on-eject-end
543
- // Babel sourcemaps are needed for debugging into node_modules
544
- // code. Without the options below, debuggers like VSCode
545
- // show incorrect code and set breakpoints on the wrong lines.
546
- sourceMaps: shouldUseSourceMap,
547
- inputSourceMap: shouldUseSourceMap,
548
- },
549
- },
550
- // "postcss" loader applies autoprefixer to our CSS.
551
- // "css" loader resolves paths in CSS and adds assets as dependencies.
552
- // "style" loader turns CSS into JS modules that inject <style> tags.
553
- // In production, we use MiniCSSExtractPlugin to extract that CSS
554
- // to a file, but in development "style" loader enables hot editing
555
- // of CSS.
556
- // By default we support CSS Modules with the extension .module.css
557
- {
558
- test: cssRegex,
559
- exclude: cssModuleRegex,
560
- use: getStyleLoaders({
561
- importLoaders: 1,
562
- sourceMap: isEnvProduction
563
- ? shouldUseSourceMap
564
- : isEnvDevelopment,
565
- modules: {
566
- mode: 'icss',
567
- },
568
- }),
569
- // Don't consider CSS imports dead code even if the
570
- // containing package claims to have no side effects.
571
- // Remove this when webpack adds a warning or an error for this.
572
- // See https://github.com/webpack/webpack/issues/6571
573
- sideEffects: true,
574
- },
575
- // Adds support for CSS Modules (https://github.com/css-modules/css-modules)
576
- // using the extension .module.css
577
- {
578
- test: cssModuleRegex,
579
- use: getStyleLoaders({
580
- importLoaders: 1,
581
- sourceMap: isEnvProduction
582
- ? shouldUseSourceMap
583
- : isEnvDevelopment,
584
- modules: {
585
- mode: 'local',
586
- getLocalIdent: getCSSModuleLocalIdent,
587
- },
588
- }),
589
- },
590
- // Opt-in support for SASS (using .scss or .sass extensions).
591
- // By default we support SASS Modules with the
592
- // extensions .module.scss or .module.sass
593
- {
594
- test: sassRegex,
595
- exclude: sassModuleRegex,
596
- use: getStyleLoaders(
597
- {
598
- importLoaders: 3,
599
- sourceMap: isEnvProduction
600
- ? shouldUseSourceMap
601
- : isEnvDevelopment,
602
- modules: {
603
- mode: 'icss',
604
- },
605
- },
606
- 'sass-loader'
607
- ),
608
- // Don't consider CSS imports dead code even if the
609
- // containing package claims to have no side effects.
610
- // Remove this when webpack adds a warning or an error for this.
611
- // See https://github.com/webpack/webpack/issues/6571
612
- sideEffects: true,
613
- },
614
- // Adds support for CSS Modules, but using SASS
615
- // using the extension .module.scss or .module.sass
616
- {
617
- test: sassModuleRegex,
618
- use: getStyleLoaders(
619
- {
620
- importLoaders: 3,
621
- sourceMap: isEnvProduction
622
- ? shouldUseSourceMap
623
- : isEnvDevelopment,
624
- modules: {
625
- mode: 'local',
626
- getLocalIdent: getCSSModuleLocalIdent,
627
- },
628
- },
629
- 'sass-loader'
630
- ),
631
- },
632
- // "file" loader makes sure those assets get served by WebpackDevServer.
633
- // When you `import` an asset, you get its (virtual) filename.
634
- // In production, they would get copied to the `build` folder.
635
- // This loader doesn't use a "test" so it will catch all modules
636
- // that fall through the other loaders.
637
- {
638
- // Exclude `js` files to keep "css" loader working as it injects
639
- // its runtime that would otherwise be processed through "file" loader.
640
- // Also exclude `html` and `json` extensions so they get processed
641
- // by webpacks internal loaders.
642
- exclude: [/^$/, /\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
643
- type: 'asset/resource',
644
- },
645
- // ** STOP ** Are you adding a new loader?
646
- // Make sure to add the new loader(s) before the "file" loader.
647
- ],
648
- },
649
- ].filter(Boolean),
650
- },
651
- plugins: [
652
- // Generates an `index.html` file with the <script> injected.
653
- new HtmlWebpackPlugin(
654
- Object.assign(
655
- {},
656
- {
657
- inject: true,
658
- template: paths.appHtml,
659
- },
660
- isEnvProduction
661
- ? {
662
- minify: {
663
- removeComments: true,
664
- collapseWhitespace: true,
665
- removeRedundantAttributes: true,
666
- useShortDoctype: true,
667
- removeEmptyAttributes: true,
668
- removeStyleLinkTypeAttributes: true,
669
- keepClosingSlash: true,
670
- minifyJS: true,
671
- minifyCSS: true,
672
- minifyURLs: true,
673
- },
674
- }
675
- : undefined
676
- )
677
- ),
678
- // Inlines the webpack runtime script. This script is too small to warrant
679
- // a network request.
680
- // https://github.com/facebook/create-react-app/issues/5358
681
- isEnvProduction &&
682
- shouldInlineRuntimeChunk &&
683
- new InlineChunkHtmlPlugin(HtmlWebpackPlugin, [/runtime-.+[.]js/]),
684
- // Makes some environment variables available in index.html.
685
- // The public URL is available as %PUBLIC_URL% in index.html, e.g.:
686
- // <link rel="icon" href="%PUBLIC_URL%/favicon.ico">
687
- // It will be an empty string unless you specify "homepage"
688
- // in `package.json`, in which case it will be the pathname of that URL.
689
- new InterpolateHtmlPlugin(HtmlWebpackPlugin, env.raw),
690
- // This gives some necessary context to module not found errors, such as
691
- // the requesting resource.
692
- new ModuleNotFoundPlugin(paths.appPath),
693
- // Makes some environment variables available to the JS code, for example:
694
- // if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`.
695
- // It is absolutely essential that NODE_ENV is set to production
696
- // during a production build.
697
- // Otherwise React will be compiled in the very slow development mode.
698
- new webpack.DefinePlugin(env.stringified),
699
- // Experimental hot reloading for React .
700
- // https://github.com/facebook/react/tree/main/packages/react-refresh
701
- isEnvDevelopment &&
702
- shouldUseReactRefresh &&
703
- new ReactRefreshWebpackPlugin({
704
- overlay: false,
705
- }),
706
- // Watcher doesn't work well if you mistype casing in a path so we use
707
- // a plugin that prints an error when you attempt to do this.
708
- // See https://github.com/facebook/create-react-app/issues/240
709
- isEnvDevelopment && new CaseSensitivePathsPlugin(),
710
- isEnvProduction &&
711
- new MiniCssExtractPlugin({
712
- // Options similar to the same options in webpackOptions.output
713
- // both options are optional
714
- // JsView Modified >>>
715
- // 修改Css文件名
716
- // filename: 'static/css/[name].[contenthash:8].css',
717
- // chunkFilename: 'static/css/[name].[contenthash:8].chunk.css',
718
- filename: 'css/[name].[contenthash:8].css',
719
- chunkFilename: 'css/[name].[contenthash:8].chunk.css',
720
- // JsView Modified <<<
721
- }),
722
- // Generate an asset manifest file with the following content:
723
- // - "files" key: Mapping of all asset filenames to their corresponding
724
- // output file so that tools can pick it up without having to parse
725
- // `index.html`
726
- // - "entrypoints" key: Array of files which are included in `index.html`,
727
- // can be used to reconstruct the HTML if necessary
728
- new WebpackManifestPlugin({
729
- fileName: 'asset-manifest.json',
730
- publicPath: paths.publicUrlOrPath,
731
- generate: (seed, files, entrypoints) => {
732
- const manifestFiles = files.reduce((manifest, file) => {
733
- manifest[file.name] = file.path;
734
- return manifest;
735
- }, seed);
736
- const entrypointFiles = entrypoints.main.filter(
737
- fileName => !fileName.endsWith('.map')
738
- );
739
-
740
- return {
741
- files: manifestFiles,
742
- entrypoints: entrypointFiles,
743
- };
744
- },
745
- }),
746
- // Moment.js is an extremely popular library that bundles large locale files
747
- // by default due to how webpack interprets its code. This is a practical
748
- // solution that requires the user to opt into importing specific locales.
749
- // https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
750
- // You can remove this if you don't use Moment.js:
751
- new webpack.IgnorePlugin({
752
- resourceRegExp: /^\.\/locale$/,
753
- contextRegExp: /moment$/,
754
- }),
755
- // Generate a service worker script that will precache, and keep up to date,
756
- // the HTML & assets that are part of the webpack build.
757
- isEnvProduction &&
758
- fs.existsSync(swSrc) &&
759
- new WorkboxWebpackPlugin.InjectManifest({
760
- swSrc,
761
- dontCacheBustURLsMatching: /\.[0-9a-f]{8}\./,
762
- exclude: [/\.map$/, /asset-manifest\.json$/, /LICENSE/],
763
- // Bump up the default maximum size (2mb) that's precached,
764
- // to make lazy-loading failure scenarios less likely.
765
- // See https://github.com/cra-template/pwa/issues/13#issuecomment-722667270
766
- maximumFileSizeToCacheInBytes: 5 * 1024 * 1024,
767
- }),
768
- // TypeScript type checking
769
- useTypeScript &&
770
- new ForkTsCheckerWebpackPlugin({
771
- async: isEnvDevelopment,
772
- typescript: {
773
- typescriptPath: resolve.sync('typescript', {
774
- basedir: paths.appNodeModules,
775
- }),
776
- configOverwrite: {
777
- compilerOptions: {
778
- sourceMap: isEnvProduction
779
- ? shouldUseSourceMap
780
- : isEnvDevelopment,
781
- skipLibCheck: true,
782
- inlineSourceMap: false,
783
- declarationMap: false,
784
- noEmit: true,
785
- incremental: true,
786
- tsBuildInfoFile: paths.appTsBuildInfoFile,
787
- },
788
- },
789
- context: paths.appPath,
790
- diagnosticOptions: {
791
- syntactic: true,
792
- },
793
- mode: 'write-references',
794
- // profile: true,
795
- },
796
- issue: {
797
- // This one is specifically to match during CI tests,
798
- // as micromatch doesn't match
799
- // '../cra-template-typescript/template/src/App.tsx'
800
- // otherwise.
801
- include: [
802
- { file: '../**/src/**/*.{ts,tsx}' },
803
- { file: '**/src/**/*.{ts,tsx}' },
804
- ],
805
- exclude: [
806
- { file: '**/src/**/__tests__/**' },
807
- { file: '**/src/**/?(*.){spec|test}.*' },
808
- { file: '**/src/setupProxy.*' },
809
- { file: '**/src/setupTests.*' },
810
- ],
811
- },
812
- logger: {
813
- infrastructure: 'silent',
814
- },
815
- }),
816
- !disableESLintPlugin &&
817
- new ESLintPlugin({
818
- // Plugin options
819
- extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
820
- formatter: require.resolve('react-dev-utils/eslintFormatter'),
821
- eslintPath: require.resolve('eslint'),
822
- failOnError: !(isEnvDevelopment && emitErrorsAsWarnings),
823
- context: paths.appSrc,
824
- cache: true,
825
- cacheLocation: path.resolve(
826
- paths.appNodeModules,
827
- '.cache/.eslintcache'
828
- ),
829
- // ESLint class options
830
- cwd: paths.appPath,
831
- resolvePluginsRelativeTo: __dirname,
832
- baseConfig: {
833
- extends: [require.resolve('eslint-config-react-app/base')],
834
- rules: {
835
- ...(!hasJsxRuntime && {
836
- 'react/react-in-jsx-scope': 'error',
837
- }),
838
- },
839
- },
840
- }),
841
- ].filter(Boolean),
842
- // Turn off performance processing because we utilize
843
- // our own hints via the FileSizeReporter
844
- performance: false,
845
-
846
- // JsView Added >>>
847
- experiments: {
848
- topLevelAwait: true
849
- },
850
- ignoreWarnings: [
851
- {
852
- module: /@shijiu\/jsview/,
853
- message: /Critical dependency: the request of a dependency is an expression/,
854
- },
855
- ],
856
- // JsView Added <<<
857
- };
858
- };