@griddo/ax 12.3.0-beta.0 → 12.3.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.
@@ -2,26 +2,23 @@ const fs = require("fs");
2
2
  const path = require("path");
3
3
  const webpack = require("webpack");
4
4
  const resolve = require("resolve");
5
- const PnpWebpackPlugin = require("pnp-webpack-plugin");
6
5
  const HtmlWebpackPlugin = require("html-webpack-plugin");
7
6
  const CaseSensitivePathsPlugin = require("case-sensitive-paths-webpack-plugin");
8
7
  const InlineChunkHtmlPlugin = require("react-dev-utils/InlineChunkHtmlPlugin");
9
8
  const TerserPlugin = require("terser-webpack-plugin");
10
9
  const MiniCssExtractPlugin = require("mini-css-extract-plugin");
11
- const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
12
- const safePostCssParser = require("postcss-safe-parser");
13
- const ManifestPlugin = require("webpack-manifest-plugin");
10
+ const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
11
+ const { WebpackManifestPlugin } = require("webpack-manifest-plugin");
14
12
  const InterpolateHtmlPlugin = require("react-dev-utils/InterpolateHtmlPlugin");
15
- const WorkboxWebpackPlugin = require("workbox-webpack-plugin");
16
- const WatchMissingNodeModulesPlugin = require("react-dev-utils/WatchMissingNodeModulesPlugin");
17
13
  const getCSSModuleLocalIdent = require("react-dev-utils/getCSSModuleLocalIdent");
18
14
  const paths = require("./paths");
19
15
  const modules = require("./modules");
20
16
  const getClientEnvironment = require("./env");
21
17
  const ModuleNotFoundPlugin = require("react-dev-utils/ModuleNotFoundPlugin");
22
18
  const ForkTsCheckerWebpackPlugin = require("react-dev-utils/ForkTsCheckerWebpackPlugin");
23
- const typescriptFormatter = require("react-dev-utils/typescriptFormatter");
24
19
  const ReactRefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin");
20
+ const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
21
+ const createEnvironmentHash = require("./webpack/persistentCache/createEnvironmentHash");
25
22
 
26
23
  const postcssNormalize = require("postcss-normalize");
27
24
 
@@ -51,9 +48,6 @@ const appPackageJson = require(paths.appPackageJson);
51
48
  // Source maps are resource heavy and can cause out of memory issue for large source files.
52
49
  const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== "false";
53
50
 
54
- const webpackDevClientEntry = require.resolve("react-dev-utils/webpackHotDevClient");
55
- const reactRefreshOverlayEntry = require.resolve("react-dev-utils/refreshOverlayInterop");
56
-
57
51
  // Some apps do not need the benefits of saving a web request, so not inlining the chunk
58
52
  // makes for a smoother build process.
59
53
  const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK !== "false";
@@ -63,8 +57,9 @@ const imageInlineSizeLimit = parseInt(process.env.IMAGE_INLINE_SIZE_LIMIT || "10
63
57
  // Check if TypeScript is setup
64
58
  const useTypeScript = fs.existsSync(paths.appTsConfig);
65
59
 
66
- // Get the path to the uncompiled service worker (if it exists).
67
- const swSrc = paths.swSrc;
60
+ // CI runners are memory-capped containers with a throwaway filesystem, so webpack 5
61
+ // defaults that assume a long-lived dev machine work against us there.
62
+ const isCI = process.env.CI === "true";
68
63
 
69
64
  // style files regexes
70
65
  const cssRegex = /\.css$/;
@@ -115,7 +110,9 @@ module.exports = function (webpackEnv) {
115
110
  },
116
111
  {
117
112
  loader: require.resolve("css-loader"),
118
- options: cssOptions,
113
+ options: {
114
+ ...cssOptions,
115
+ },
119
116
  },
120
117
  {
121
118
  // Options for PostCSS as we reference these options twice
@@ -123,26 +120,23 @@ module.exports = function (webpackEnv) {
123
120
  // package.json
124
121
  loader: require.resolve("postcss-loader"),
125
122
  options: {
126
- // Necessary for external CSS imports to work
127
- // https://github.com/facebook/create-react-app/issues/2677
128
- ident: "postcss",
129
- plugins: () => [
130
- require("postcss-flexbugs-fixes"),
131
- require("postcss-preset-env")({
132
- autoprefixer: {
133
- flexbox: "no-2009",
134
- },
135
- stage: 3,
136
- }),
137
-
138
- // PostCSS plugins from components.
139
- ...postcssConfigPlugins,
140
-
141
- // Adds PostCSS Normalize as the reset css with default options,
142
- // so that it honors browserslist config in package.json
143
- // which in turn let's users customize the target behavior as per their needs.
144
- postcssNormalize(),
145
- ],
123
+ postcssOptions: {
124
+ plugins: [
125
+ require("postcss-flexbugs-fixes"),
126
+ require("postcss-preset-env")({
127
+ autoprefixer: {
128
+ flexbox: "no-2009",
129
+ },
130
+ stage: 3,
131
+ }),
132
+ // PostCSS plugins from components.
133
+ ...postcssConfigPlugins,
134
+ // Adds PostCSS Normalize as the reset css with default options,
135
+ // so that it honors browserslist config in package.json.
136
+ // postcss-preset-env 6 does not bundle normalize, so we keep it.
137
+ postcssNormalize(),
138
+ ],
139
+ },
146
140
  sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
147
141
  },
148
142
  },
@@ -160,7 +154,8 @@ module.exports = function (webpackEnv) {
160
154
  {
161
155
  loader: require.resolve(preProcessor),
162
156
  options: {
163
- sourceMap: true,
157
+ api: "modern-compiler",
158
+ sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
164
159
  ...preProcessorOptions,
165
160
  },
166
161
  },
@@ -171,6 +166,11 @@ module.exports = function (webpackEnv) {
171
166
 
172
167
  return {
173
168
  mode: isEnvProduction ? "production" : isEnvDevelopment && "development",
169
+ // Pin the target instead of letting webpack 5 derive it from the client
170
+ // project's browserslist: queries like "maintained node versions" (common
171
+ // in Gatsby-rendered projects) drop the `document` capability and switch
172
+ // chunks to ESM format, which breaks the editor's classic script tags.
173
+ target: ["web", "es2017"],
174
174
  // Stop compilation early in production
175
175
  bail: isEnvProduction,
176
176
  devtool: isEnvProduction
@@ -180,31 +180,7 @@ module.exports = function (webpackEnv) {
180
180
  : isEnvDevelopment && "cheap-module-source-map",
181
181
  // These are the "entry points" to our application.
182
182
  // This means they will be the "root" imports that are included in JS bundle.
183
- entry:
184
- isEnvDevelopment && !shouldUseReactRefresh
185
- ? [
186
- // Include an alternative client for WebpackDevServer. A client's job is to
187
- // connect to WebpackDevServer by a socket and get notified about changes.
188
- // When you save a file, the client will either apply hot updates (in case
189
- // of CSS changes), or refresh the page (in case of JS changes). When you
190
- // make a syntax error, this client will display a syntax error overlay.
191
- // Note: instead of the default WebpackDevServer client, we use a custom one
192
- // to bring better experience for Create React App users. You can replace
193
- // the line below with these two lines if you prefer the stock client:
194
- //
195
- // require.resolve('webpack-dev-server/client') + '?/',
196
- // require.resolve('webpack/hot/dev-server'),
197
- //
198
- // When using the experimental react-refresh integration,
199
- // the webpack plugin takes care of injecting the dev client for us.
200
- webpackDevClientEntry,
201
- // Finally, this is your app's code:
202
- paths.appIndexJs,
203
- // We include the app code last so that if there is a runtime error during
204
- // initialization, it doesn't blow up the WebpackDevServer client, and
205
- // changing JS code would still trigger a refresh.
206
- ]
207
- : paths.appIndexJs,
183
+ entry: paths.appIndexJs,
208
184
  output: {
209
185
  // The build folder.
210
186
  path: isEnvProduction ? paths.appBuild : undefined,
@@ -212,13 +188,12 @@ module.exports = function (webpackEnv) {
212
188
  pathinfo: isEnvDevelopment,
213
189
  // There will be one main bundle, and one file per asynchronous chunk.
214
190
  // In development, it does not produce real files.
215
- filename: isEnvProduction ? "static/js/[name].[contenthash:8].js" : isEnvDevelopment && "static/js/bundle.js",
216
- // TODO: remove this when upgrading to webpack 5
217
- futureEmitAssets: true,
191
+ filename: isEnvProduction ? "static/js/[name].[contenthash:8].js" : isEnvDevelopment && "static/js/[name].js",
218
192
  // There are also additional JS chunk files if you use code splitting.
219
193
  chunkFilename: isEnvProduction
220
194
  ? "static/js/[name].[contenthash:8].chunk.js"
221
195
  : isEnvDevelopment && "static/js/[name].chunk.js",
196
+ assetModuleFilename: "static/media/[name].[contenthash:8][ext]",
222
197
  // webpack uses `publicPath` to determine where the app is being served from.
223
198
  // It requires a trailing slash, or the file assets will get an incorrect path.
224
199
  // We inferred the "public path" (such as / or /my-project) from homepage.
@@ -229,16 +204,40 @@ module.exports = function (webpackEnv) {
229
204
  : isEnvDevelopment && ((info) => path.resolve(info.absoluteResourcePath).replace(/\\/g, "/")),
230
205
  // Prevents conflicts when multiple webpack runtimes (from different apps)
231
206
  // are used on the same page.
232
- jsonpFunction: `webpackJsonp${appPackageJson.name}`,
207
+ chunkLoadingGlobal: `webpackJsonp${appPackageJson.name}`,
233
208
  // this defaults to 'window', but by setting it to 'this' then
234
209
  // module chunks which are built will work in web workers as well.
235
210
  globalObject: "this",
211
+ // Node.js 17+ (OpenSSL 3.0) dropped MD4, webpack 5's default hash function.
212
+ // xxhash64 avoids the `digital envelope routines::unsupported` error and lets
213
+ // us drop the `--openssl-legacy-provider` workaround.
214
+ hashFunction: "xxhash64",
236
215
  },
216
+ // The persistent cache pays off on a dev machine, but CI installs node_modules
217
+ // from scratch on every run: the ~640 MB pack is built, held in memory to be
218
+ // serialized and then thrown away, for zero reuse.
219
+ cache: isCI
220
+ ? false
221
+ : {
222
+ type: "filesystem",
223
+ version: createEnvironmentHash(env.raw),
224
+ cacheDirectory: paths.appWebpackCache,
225
+ store: "pack",
226
+ buildDependencies: {
227
+ defaultWebpack: ["webpack/lib/"],
228
+ config: [__filename],
229
+ tsconfig: [paths.appTsConfig].filter(Boolean),
230
+ },
231
+ },
237
232
  optimization: {
238
233
  minimize: isEnvProduction,
239
234
  minimizer: [
240
235
  // This is only used in production mode
241
236
  new TerserPlugin({
237
+ // Inside a container os.cpus() reports the host's cores, so the default
238
+ // (cores - 1) forks far more workers than the pod can feed, each one a
239
+ // Node process inheriting NODE_OPTIONS' heap ceiling.
240
+ parallel: isCI ? 2 : true,
242
241
  terserOptions: {
243
242
  parse: {
244
243
  // We want terser to parse ecma 8 code. However, we don't want it
@@ -276,34 +275,15 @@ module.exports = function (webpackEnv) {
276
275
  ascii_only: true,
277
276
  },
278
277
  },
279
- sourceMap: shouldUseSourceMap,
280
278
  }),
281
279
  // This is only used in production mode
282
- new OptimizeCSSAssetsPlugin({
283
- cssProcessorOptions: {
284
- parser: safePostCssParser,
285
- map: shouldUseSourceMap
286
- ? {
287
- // `inline: false` forces the sourcemap to be output into a
288
- // separate file
289
- inline: false,
290
- // `annotation: true` appends the sourceMappingURL to the end of
291
- // the css file, helping the browser find the sourcemap
292
- annotation: true,
293
- }
294
- : false,
295
- },
296
- cssProcessorPluginOptions: {
297
- preset: ["default", { minifyFontValues: { removeQuotes: false } }],
298
- },
299
- }),
280
+ new CssMinimizerPlugin(),
300
281
  ],
301
282
  // Automatically split vendor and commons
302
283
  // https://twitter.com/wSokra/status/969633336732905474
303
284
  // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
304
285
  splitChunks: {
305
286
  chunks: "all",
306
- name: isEnvDevelopment,
307
287
  },
308
288
  // Keep the runtime chunk separated to enable long term caching
309
289
  // https://twitter.com/wSokra/status/969679223278505985
@@ -339,49 +319,60 @@ module.exports = function (webpackEnv) {
339
319
  ...(modules.webpackAliases || {}),
340
320
  ...projectAliases,
341
321
  },
342
- plugins: [
343
- // Adds support for installing with Plug'n'Play, leading to faster installs and adding
344
- // guards against forgotten dependencies and such.
345
- PnpWebpackPlugin,
346
- ],
347
- },
348
- resolveLoader: {
349
- plugins: [
350
- // Also related to Plug'n'Play, but this time it tells webpack to load its loaders
351
- // from the current package.
352
- PnpWebpackPlugin.moduleLoader(module),
353
- ],
322
+ // Stub Node builtins that have no browser equivalent (webpack 4 mocked these via
323
+ // its old core-module block: module, dgram, dns, fs, http2, net, tls, child_process).
324
+ // Everything with a browser polyfill (buffer, stream, crypto, http, https, zlib,
325
+ // util, process, ...) is provided by NodePolyfillPlugin, restoring webpack 4's
326
+ // auto-polyfill behaviour so legacy client instances keep building.
327
+ fallback: {
328
+ fs: false,
329
+ net: false,
330
+ tls: false,
331
+ child_process: false,
332
+ dns: false,
333
+ http2: false,
334
+ module: false,
335
+ dgram: false,
336
+ },
354
337
  },
355
338
  module: {
356
- strictExportPresence: true,
339
+ // Missing exports must stay non-blocking: webpack 4's CJS css-loader
340
+ // never validated CSS-module classes, so client projects accumulated
341
+ // references to classes that don't exist. With webpack 5 named exports
342
+ // those would all become compile errors and block adoption.
343
+ parser: {
344
+ javascript: {
345
+ exportsPresence: "warn",
346
+ },
347
+ },
357
348
  rules: [
358
- // Disable require.ensure as it's not a standard language feature.
359
- { parser: { requireEnsure: false } },
360
349
  {
361
350
  // "oneOf" will traverse all following loaders until one will
362
351
  // match the requirements. When no loader matches it will fall
363
- // back to the "file" loader at the end of the loader list.
352
+ // back to the "resource" asset module at the end of the loader list.
364
353
  oneOf: [
365
354
  // TODO: Merge this config once `image/avif` is in the mime-db
366
355
  // https://github.com/jshttp/mime-db
367
356
  {
368
357
  test: [/\.avif$/],
369
- loader: require.resolve("url-loader"),
370
- options: {
371
- limit: imageInlineSizeLimit,
372
- mimetype: "image/avif",
373
- name: "static/media/[name].[hash:8].[ext]",
358
+ type: "asset",
359
+ mimetype: "image/avif",
360
+ parser: {
361
+ dataUrlCondition: {
362
+ maxSize: imageInlineSizeLimit,
363
+ },
374
364
  },
375
365
  },
376
- // "url" loader works like "file" loader except that it embeds assets
366
+ // "asset" loader works like "file" loader except that it embeds assets
377
367
  // smaller than specified limit in bytes as data URLs to avoid requests.
378
368
  // A missing `test` is equivalent to a match.
379
369
  {
380
370
  test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
381
- loader: require.resolve("url-loader"),
382
- options: {
383
- limit: imageInlineSizeLimit,
384
- name: "static/media/[name].[hash:8].[ext]",
371
+ type: "asset",
372
+ parser: {
373
+ dataUrlCondition: {
374
+ maxSize: imageInlineSizeLimit,
375
+ },
385
376
  },
386
377
  },
387
378
  // Process application JS with Babel.
@@ -475,6 +466,17 @@ module.exports = function (webpackEnv) {
475
466
  importLoaders: 1,
476
467
  sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
477
468
  modules: {
469
+ // css-loader v6 defaults `esModule: true`, so `import * as styles`
470
+ // only sees locals as named exports when `namedExport` is on.
471
+ // griddo-components relies on `import * as styles` heavily.
472
+ namedExport: true,
473
+ // `asIs` keeps the webpack 4 class names, so `styles["heading-sm"]`
474
+ // keeps working in client projects. css-loader derives
475
+ // `useExportsAs` from this value and emits
476
+ // `export { _1 as "heading-sm" }` instead of the invalid
477
+ // `export var heading-sm`. camelCaseOnly is what we must avoid:
478
+ // it would turn `@keyframes _in` into `export var in` (reserved word).
479
+ exportLocalsConvention: "asIs",
478
480
  getLocalIdent: getCSSModuleLocalIdent,
479
481
  },
480
482
  }),
@@ -507,6 +509,8 @@ module.exports = function (webpackEnv) {
507
509
  importLoaders: 3,
508
510
  sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
509
511
  modules: {
512
+ namedExport: true,
513
+ exportLocalsConvention: "asIs",
510
514
  getLocalIdent: getCSSModuleLocalIdent,
511
515
  },
512
516
  },
@@ -515,30 +519,20 @@ module.exports = function (webpackEnv) {
515
519
  },
516
520
  {
517
521
  test: /\.(woff|woff2)$/,
518
- use: ["url-loader"],
522
+ type: "asset/resource",
519
523
  },
520
524
  {
521
525
  test: /\.svg$/,
522
526
  use: ["@svgr/webpack"],
523
527
  },
524
- // "file" loader makes sure those assets get served by WebpackDevServer.
525
- // When you `import` an asset, you get its (virtual) filename.
526
- // In production, they would get copied to the `build` folder.
527
- // This loader doesn't use a "test" so it will catch all modules
528
- // that fall through the other loaders.
528
+ // Catch-all: anything not handled above is emitted as a separate file.
529
+ // This replaces the old file-loader catch-all.
529
530
  {
530
- loader: require.resolve("file-loader"),
531
- // Exclude `js` files to keep "css" loader working as it injects
532
- // its runtime that would otherwise be processed through "file" loader.
533
- // Also exclude `html` and `json` extensions so they get processed
534
- // by webpacks internal loaders.
535
531
  exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
536
- options: {
537
- name: "static/media/[name].[hash:8].[ext]",
538
- },
532
+ type: "asset/resource",
539
533
  },
540
534
  // ** STOP ** Are you adding a new loader?
541
- // Make sure to add the new loader(s) before the "file" loader.
535
+ // Make sure to add the new loader(s) before the "asset/resource" catch-all.
542
536
  ],
543
537
  },
544
538
  {
@@ -549,6 +543,12 @@ module.exports = function (webpackEnv) {
549
543
  ],
550
544
  },
551
545
  plugins: [
546
+ // Restore webpack 4's Node core-module handling for browser bundles. Clients run
547
+ // `griddo build` (this config) against their own instance, so this guards legacy
548
+ // instances against "Module not found" for Node builtins that webpack 5 no longer
549
+ // polyfills automatically. Browser-polyfillable builtins are provided here; the
550
+ // server-only ones are stubbed via resolve.fallback above.
551
+ new NodePolyfillPlugin(),
552
552
  // Generates an `index.html` file with the <script> injected.
553
553
  new HtmlWebpackPlugin(
554
554
  Object.assign(
@@ -594,32 +594,23 @@ module.exports = function (webpackEnv) {
594
594
  // during a production build.
595
595
  // Otherwise React will be compiled in the very slow development mode.
596
596
  new webpack.DefinePlugin(env.stringified),
597
- // This is necessary to emit hot updates (CSS and Fast Refresh):
598
- isEnvDevelopment && new webpack.HotModuleReplacementPlugin(),
599
- // Experimental hot reloading for React .
597
+ // HMR is handled by WebpackDevServer 4 (`hot: true` in webpackDevServer.config.js),
598
+ // which registers HotModuleReplacementPlugin automatically. We no longer add it
599
+ // manually to avoid a duplicate-plugin instance.
600
+ // Experimental hot reloading for React (Fast Refresh).
600
601
  // https://github.com/facebook/react/tree/master/packages/react-refresh
601
602
  isEnvDevelopment &&
602
603
  shouldUseReactRefresh &&
603
604
  new ReactRefreshWebpackPlugin({
604
- overlay: {
605
- entry: webpackDevClientEntry,
606
- // The expected exports are slightly different from what the overlay exports,
607
- // so an interop is included here to enable feedback on module-level errors.
608
- module: reactRefreshOverlayEntry,
609
- // Since we ship a custom dev client and overlay integration,
610
- // the bundled socket handling logic can be eliminated.
611
- sockIntegration: false,
612
- },
605
+ // The error overlay is served by WebpackDevServer 4's native client
606
+ // (see `client.overlay` in webpackDevServer.config.js). Disable the
607
+ // Fast Refresh plugin overlay to avoid two overlays fighting.
608
+ overlay: false,
613
609
  }),
614
610
  // Watcher doesn't work well if you mistype casing in a path so we use
615
611
  // a plugin that prints an error when you attempt to do this.
616
612
  // See https://github.com/facebook/create-react-app/issues/240
617
613
  isEnvDevelopment && new CaseSensitivePathsPlugin(),
618
- // If you require a missing module and then `npm install` it, you still have
619
- // to restart the development server for webpack to discover it. This plugin
620
- // makes the discovery automatic so you don't have to restart.
621
- // See https://github.com/facebook/create-react-app/issues/186
622
- isEnvDevelopment && new WatchMissingNodeModulesPlugin(paths.appNodeModules),
623
614
  isEnvProduction &&
624
615
  new MiniCssExtractPlugin({
625
616
  // Options similar to the same options in webpackOptions.output
@@ -633,7 +624,7 @@ module.exports = function (webpackEnv) {
633
624
  // `index.html`
634
625
  // - "entrypoints" key: Array of files which are included in `index.html`,
635
626
  // can be used to reconstruct the HTML if necessary
636
- new ManifestPlugin({
627
+ new WebpackManifestPlugin({
637
628
  fileName: "asset-manifest.json",
638
629
  publicPath: paths.publicUrlOrPath,
639
630
  generate: (seed, files, entrypoints) => {
@@ -654,59 +645,62 @@ module.exports = function (webpackEnv) {
654
645
  // solution that requires the user to opt into importing specific locales.
655
646
  // https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
656
647
  // You can remove this if you don't use Moment.js:
657
- new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
658
- // Generate a service worker script that will precache, and keep up to date,
659
- // the HTML & assets that are part of the webpack build.
660
- isEnvProduction &&
661
- fs.existsSync(swSrc) &&
662
- new WorkboxWebpackPlugin.InjectManifest({
663
- swSrc,
664
- dontCacheBustURLsMatching: /\.[0-9a-f]{8}\./,
665
- exclude: [/\.map$/, /asset-manifest\.json$/, /LICENSE/],
666
- // Bump up the default maximum size (2mb) that's precached,
667
- // to make lazy-loading failure scenarios less likely.
668
- // See https://github.com/cra-template/pwa/issues/13#issuecomment-722667270
669
- maximumFileSizeToCacheInBytes: 5 * 1024 * 1024,
670
- }),
648
+ new webpack.IgnorePlugin({
649
+ resourceRegExp: /^\.\/locale$/,
650
+ contextRegExp: /moment$/,
651
+ }),
671
652
  // TypeScript type checking
672
653
  useTypeScript &&
673
654
  new ForkTsCheckerWebpackPlugin({
674
- typescript: resolve.sync("typescript", {
675
- basedir: paths.appNodeModules,
676
- }),
677
655
  async: isEnvDevelopment,
678
- checkSyntacticErrors: true,
679
- resolveModuleNameModule: process.versions.pnp ? `${__dirname}/pnpTs.js` : undefined,
680
- resolveTypeReferenceDirectiveModule: process.versions.pnp ? `${__dirname}/pnpTs.js` : undefined,
681
- tsconfig: paths.appTsConfig,
682
- reportFiles: [
683
- // This one is specifically to match during CI tests,
684
- // as micromatch doesn't match
685
- // '../cra-template-typescript/template/src/App.tsx'
686
- // otherwise.
687
- "../**/src/**/*.{ts,tsx}",
688
- "**/src/**/*.{ts,tsx}",
689
- "!**/src/**/__tests__/**",
690
- "!**/src/**/?(*.)(spec|test).*",
691
- "!**/src/setupProxy.*",
692
- "!**/src/setupTests.*",
693
- ],
694
- silent: true,
695
- // The formatter is invoked directly in WebpackDevServerUtils during development
696
- formatter: isEnvProduction ? typescriptFormatter : undefined,
656
+ typescript: {
657
+ typescriptPath: resolve.sync("typescript", {
658
+ basedir: paths.appNodeModules,
659
+ }),
660
+ // Must be an absolute path: fork-ts-checker v6 resolves a relative
661
+ // "tsconfig.json" against the webpack compiler context (the client
662
+ // project cwd), which would pick up the client's tsconfig instead.
663
+ configFile: paths.appTsConfig,
664
+ configOverwrite: {
665
+ compilerOptions: {
666
+ sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
667
+ skipLibCheck: true,
668
+ inlineSourceMap: false,
669
+ declarationMap: false,
670
+ noEmit: true,
671
+ incremental: true,
672
+ tsBuildInfoFile: paths.appTsBuildInfoFile,
673
+ },
674
+ },
675
+ context: paths.appPath,
676
+ diagnosticOptions: {
677
+ syntactic: true,
678
+ },
679
+ mode: "write-references",
680
+ },
681
+ issue: {
682
+ include: [{ file: "../**/src/**/*.{ts,tsx}" }, { file: "**/src/**/*.{ts,tsx}" }],
683
+ exclude: [
684
+ { file: "**/src/**/__tests__/**" },
685
+ { file: "**/src/**/?(*.)(spec|test).*" },
686
+ { file: "**/src/setupProxy.*" },
687
+ { file: "**/src/setupTests.*" },
688
+ ],
689
+ },
690
+ logger: {
691
+ infrastructure: "silent",
692
+ // Progress lines ("Files successfully emitted…", "No issues
693
+ // found."). Actual TS errors still reach webpack's compilation
694
+ // and are printed by react-dev-utils.
695
+ issues: "silent",
696
+ },
697
697
  }),
698
698
  ].filter(Boolean),
699
- // Some libraries import Node modules but don't use them in the browser.
700
- // Tell webpack to provide empty mocks for them so importing them works.
701
- node: {
702
- module: "empty",
703
- dgram: "empty",
704
- dns: "mock",
705
- fs: "empty",
706
- http2: "empty",
707
- net: "empty",
708
- tls: "empty",
709
- child_process: "empty",
699
+ // Silence webpack-dev-middleware's stats dump on every (re)build
700
+ // webpack 4's dev server did this via `quiet: true`. react-dev-utils
701
+ // still prints the friendly "Compiled successfully" + URLs block.
702
+ infrastructureLogging: {
703
+ level: "none",
710
704
  },
711
705
  // Turn off performance processing because we utilize
712
706
  // our own hints via the FileSizeReporter