@@ -5,7 +5,6 @@ const BASE_PATH = process.env.BASE_PATH ?? "/";
5
5
const basePath = BASE_PATH == "/" ? "" : BASE_PATH ;
6
6
7
7
const { join, resolve } = require ( "path" ) ;
8
- const withRspack = require ( "next-rspack" ) ;
9
8
10
9
// Important! We include resolve('.') and basePath to avoid
11
10
// any possibility of multiple cocalc installs or different base
@@ -16,73 +15,41 @@ const cacheDirectory = join(
16
15
resolve ( "." ) ,
17
16
) ;
18
17
19
- const removeImports = require ( "next-remove-imports" ) ( ) ;
18
+ const config = {
19
+ basePath,
20
+ env : { BASE_PATH } ,
21
+ eslint : { ignoreDuringBuilds : true } ,
22
+ webpack : ( config , { buildId, dev, isServer, defaultLoaders, webpack } ) => {
23
+ // Webpack breaks without this pg-native alias, even though it's dead code,
24
+ // due to how the pg module does package detection internally.
25
+ config . resolve . alias [ "pg-native" ] = "." ;
26
+ // These aliases are so we don't end up with two distinct copies
27
+ // of React in our application, since this doesn't work at all!
28
+ config . resolve . alias [ "react" ] = resolve ( __dirname , "node_modules" , "react" ) ;
29
+ config . resolve . alias [ "react-dom" ] = resolve (
30
+ __dirname ,
31
+ "node_modules" ,
32
+ "react-dom" ,
33
+ ) ;
34
+ // Important: return the modified config
35
+ return config ;
36
+ } ,
37
+ // For i18n, see https://nextjs.org/docs/advanced-features/i18n-routing
38
+ // We are doing this at all since it improves our Lighthouse accessibility score.
39
+ i18n : {
40
+ locales : [ "en-US" ] ,
41
+ defaultLocale : "en-US" ,
42
+ } ,
43
+ poweredByHeader : false ,
44
+ } ;
20
45
21
- module . exports = withRspack (
22
- removeImports ( {
23
- basePath,
24
- swcMinify : true , // enable faster RUST-based minifier
25
- env : { BASE_PATH } ,
26
- reactStrictMode : false , // See https://github.com/ant-design/ant-design/issues/26136
27
- eslint : { ignoreDuringBuilds : true } ,
28
- // typescript: { ignoreBuildErrors: true },
29
- webpack : ( config , { buildId, dev, isServer, defaultLoaders, webpack } ) => {
30
- config . cache = {
31
- type : "filesystem" ,
32
- buildDependencies : {
33
- config : [ __filename ] ,
34
- } ,
35
- cacheDirectory,
36
- } ;
37
- // Webpack breaks without this pg-native alias, even though it's dead code,
38
- // due to how the pg module does package detection internally.
39
- config . resolve . alias [ "pg-native" ] = "." ;
40
- // These aliases are so we don't end up with two distinct copies
41
- // of React in our application, since this doesn't work at all!
42
- config . resolve . alias [ "react" ] = resolve (
43
- __dirname ,
44
- "node_modules" ,
45
- "react" ,
46
- ) ;
47
- config . resolve . alias [ "react-dom" ] = resolve (
48
- __dirname ,
49
- "node_modules" ,
50
- "react-dom" ,
51
- ) ;
52
- config . ignoreWarnings = [
53
- // This yargs warning is caused by node-zendesk in the @cocalc/server package
54
- // being a generally bad citizen. Things seem to work fine (we barely use the
55
- // zendesk api anyways).
56
- { module : / ^ \. \. \/ s e r v e r \/ n o d e _ m o d u l e s \/ y a r g s .* / } ,
57
- ] ;
46
+ const withRspack = require ( "next-rspack" ) ;
47
+ // use NO_RSPACK to build without RSPACK. This is useful on a machine with a lot
48
+ // of RAM (and patience) since it supports hot module reloading (so you don't have
49
+ // to refresh after making changes).
58
50
59
- // Important: return the modified config
60
- return config ;
61
- } ,
62
- experimental : {
63
- // This is because the debug module color support would otherwise log this warning constantly:
64
- // Module not found: ESM packages (supports-color) need to be imported. Use 'import' to
65
- // reference the package instead. https://nextjs.org/docs/messages/import-esm-externals
66
- // esmExternals: "loose", // not supported by turbopack
67
- // We raise largePageDataBytes since this was recently added, and breaks a lot of SSR rendering
68
- // for cocalc share server. By default this is 128 * 1000 = "128KB", and we are changing it to
69
- // 128 * 1000 * 15 = "1MB" for now. TODO: Obviously, it would be nice to fix the root causes of this
70
- // being too big, but that's for another day, since our production website is broken right now.
71
- largePageDataBytes : 128 * 1000 * 10 ,
72
- // If you click the back button in the browser, it should go back to the previous page and restore the scroll position.
73
- // With Next.js in the loop, this doesn't happen by default.
74
- // besides the ticket about this, here is a blogpost about this
75
- // https://www.joshwcomeau.com/react/nextjs-scroll-restoration/
76
- scrollRestoration : true ,
77
- // https://nextjs.org/docs/app/building-your-application/optimizing/memory-usage#webpack-build-worker
78
- webpackBuildWorker : true ,
79
- } ,
80
- // For i18n, see https://nextjs.org/docs/advanced-features/i18n-routing
81
- // We are doing this at all since it improves our Lighthouse accessibility score.
82
- i18n : {
83
- locales : [ "en-US" ] ,
84
- defaultLocale : "en-US" ,
85
- } ,
86
- poweredByHeader : false , // https://github.com/sagemathinc/cocalc/issues/6101
87
- } ) ,
88
- ) ;
51
+ if ( process . env . NO_RSPACK ) {
52
+ module . exports = config ;
53
+ } else {
54
+ module . exports = withRspack ( config ) ;
55
+ }
0 commit comments