The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Build Errors

TODO: Pull subtitle into page object

Here's the error I ran into:

code_start_default_section code_end_default_section

based off: https://nextjs.org/docs/messages/failed-loading-swc

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Build Errors

-- p

Here's the error I ran into:

-- code/

8:04:21 PM: ────────────────────────────────────────────────────────────────
8:04:21 PM:   2. Build command from Netlify app                             
8:04:21 PM: ────────────────────────────────────────────────────────────────
8:04:21 PM: ​
8:04:21 PM: $ npm run build
8:04:22 PM: > build
8:04:22 PM: > next build && cp _redirects .next/
8:04:23 PM: info  - Checking validity of types...
8:04:26 PM: info  - Creating an optimized production build...
8:04:48 PM: Failed to compile.
8:04:48 PM: 
8:04:48 PM: ./node_modules/esbuild/lib/main.d.ts
8:04:48 PM: Module parse failed: Unexpected token (1:7)
8:04:48 PM: You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
8:04:48 PM: > export type Platform = 'browser' | 'node' | 'neutral';
8:04:48 PM: | export type Format = 'iife' | 'cjs' | 'esm';
8:04:48 PM: | export type Loader = 'js' | 'jsx' | 'ts' | 'tsx' | 'css' | 'json' | 'text' | 'base64' | 'file' | 'dataurl' | 'binary' | 'default';
8:04:48 PM: Import trace for requested module:
8:04:48 PM: ./node_modules/esbuild/lib/ sync ^.*\/.*$
8:04:48 PM: ./node_modules/esbuild/lib/main.js
8:04:48 PM: ./node_modules/mdx-bundler/dist/index.js
8:04:48 PM: ./utils/mdx.js
8:04:48 PM: ./pages/index.js
8:04:48 PM: ./node_modules/next/dist/build/webpack/loaders/next-serverless-loader/index.js?page=%2F&absolutePagePath=private-next-pages%2Findex.js&absoluteAppPath=private-next-pages%2F_app.js&absoluteDocumentPath=next%2Fdist%2Fpages%2F_document&absoluteErrorPath=next%2Fdist%2Fpages%2F_error&absolute404Path=&distDir=private-dot-next&buildId=oEC5XMKqJ83KbAljH91im&assetPrefix=&generateEtags=true&poweredByHeader=true&canonicalBase=&

-- /code

-- p

Setting this for the build command didn't work:

-- code/
-- bash

CI= npm run build

-- /code

-- p

This was via: https://answers.netlify.com/t/new-ci-true-build-configuration-treating-warnings-as-errors-because-process-env-ci-true/14434

-- p

Also tried this, but it didn't work:

-- code/

npm install --save-dev typescript ts-loader

-- /code

-- p

This didn't work either:

-- code/

npm i -D esbuild-loader

-- /code

-- p

Trying making a webpack.config.js file with the below, but it didn't work:

-- code/
-- json

module.exports = {
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        loader: 'esbuild-loader',
        options: {
          loader: 'ts', // Or 'ts' if you don't need tsx
          target: 'es2015',
        },
      },
    ],
  },
}

-- /code

-- p

Adding this didn't work either:

-- code/

npm i --save-dev @babel/core

-- /code

-- p

Tried switching the default install of from 13.x to 12.x but that didn't work.

-- code/

"esbuild": "^0.13.15",

-- /code

-- p

to:

-- code/

"esbuild": "^0.12.29",

-- /code

-- p

Trying this in the package.json but it didn't work.

-- code/

"build": "if [ -f ./node_modules/esbuild/lib/main.d.ts ]; then rm ./node_modules/esbuild/lib/main.d.ts; fi && next build && cp _redirects .next/",

-- /code

-- p

That got a new error:

-- code/

10:06:55 PM: warn  - Compiled with warnings
10:06:55 PM: ./node_modules/esbuild/lib/main.js
10:06:55 PM: Critical dependency: the request of a dependency is an expression
10:06:55 PM: Import trace for requested module:
10:06:55 PM: ./node_modules/mdx-bundler/dist/index.js
10:06:55 PM: ./utils/mdx.js
10:06:55 PM: ./pages/index.js
10:06:55 PM: ./node_modules/next/dist/build/webpack/loaders/next-serverless-loader/index.js?page=%2F&absolutePagePath=private-next-pages%2Findex.js&absoluteAppPath=private-next-pages%2F_app.js&absoluteDocumentPath=next%2Fdist%2Fpages%2F_document&absoluteErrorPath=next%2Fdist%2Fpages%2F_error&absolute404Path=&distDir=private-dot-next&buildId=-ZQnt2IqLYGC1__loaOnU&assetPrefix=&generateEtags=true&poweredByHeader=true&canonicalBase=&basePath=&runtimeConfig=&previewProps=%7B%22previewModeId%22%3A%226b15a5ab3397694d19f221ac8e9f687d%22%2C%22previewModeSigningKey%22%3A%2294314108aa8f1893826ebffb25a37dd3dcf95a9ba38030f3fe9600e4293136ac%22%2C%22previewModeEncryptionKey%22%3A%2211b7956bde48683b19b26f03d7627885c4bf2882a969aa52c409f2c1f4840c08%22%7D&loadedEnvFiles=W10%3D&i18n=!

-- /code

-- p

Trying to removing:

-- code/

"esbuild": "^0.13.15",

-- /code

-- p

And switching:

-- code/

"mdx-bundler": "^8.0.0",

-- /code

-- p

to:

-- code/

"mdx-bundler": "^6.0.3",

-- /code

-- p

I still haven't figured this out. All that stuff was with v8 of mdx-bundler. I'm trying to go back to v6.

-- p

NOTE: Netlify pugin v4 does not work with NextJS v12 because of the SWC compiler

-- p

Tried this in `next.config.js` config but it didn't work:

-- code/

swcMinify: false

-- /code

-- p

based off: https://nextjs.org/docs/messages/failed-loading-swc

-- p

-- hr


-- categories
-- Miscellaneous

-- metadata
-- date: 2021-11-20 20:23:14
-- id: 21cvhxnm
-- status: scratch
-- type: post
-- SCRUBBED_NEO: false
-- site: aws