tinasaurus icon indicating copy to clipboard operation
tinasaurus copied to clipboard

Docusaurus 3.0 + TinaCMS 1.5.28 not working

Open juliolugo96 opened this issue 1 year ago • 5 comments

Hi, guys!

I'm struggling to create a build of Tinasaurus with the following setup:

  • Gitlab as git provider
  • MongoDB as database adapter
  • NextJS as backend
  • Self-hosted

After I run yarn build I get the following errors:

...
--------------------------

Module not found: Error: Can't resolve 'querystring' in '/home/julio/workspace/pt/mikado/decap-mikado-docs/node_modules/openid-client/lib/helpers'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "querystring": require.resolve("querystring-es3") }'
	- install 'querystring-es3'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "querystring": false }

--------------------------

Module not found: Error: Can't resolve 'http' in '/home/julio/workspace/pt/mikado/decap-mikado-docs/node_modules/openid-client/lib/helpers'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
	- install 'stream-http'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "http": false }

--------------------------

Module not found: Error: Can't resolve 'https' in '/home/julio/workspace/pt/mikado/decap-mikado-docs/node_modules/openid-client/lib/helpers'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "https": require.resolve("https-browserify") }'
	- install 'https-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "https": false }

--------------------------

Module not found: Error: Can't resolve 'crypto' in '/home/julio/workspace/pt/mikado/decap-mikado-docs/node_modules/scmp'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
	- install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "crypto": false }

--------------------------

Module not found: Error: Can't resolve 'stream' in '/home/julio/workspace/pt/mikado/decap-mikado-docs/node_modules/socks/build/common'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
	- install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "stream": false }

--------------------------

Module not found: Error: Can't resolve 'crypto' in '/home/julio/workspace/pt/mikado/decap-mikado-docs/node_modules/@tinacms/graphql/dist'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
	- install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "crypto": false }

--------------------------

Attempted import error: 'fileURLToPath' is not exported from 'url' (imported as 'fileURLToPath').
error Command failed with exit code 1.

So, I solved this using a polyfill with Webpack, like this one (tinacms build works after this)

const webpack = require("webpack");
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");

module.exports = function (context, options) {
  return {
    name: "custom-docusaurus-webpack-config-plugin",
    configureWebpack(config, isServer, utils) {
      return {
        resolve: {
          fallback: {
            fs: isServer ? "fs" : false,
            dns: isServer ? "dns" : false,
            net: isServer ? "net" : false,
            tls: isServer ? "tls" : false,
            url: isServer ? "node:url" : "url",
          },
        },
        plugins: [
          new webpack.DefinePlugin({
            "process.versions.node": JSON.stringify(
              process.versions.node || "0.0.0"
            ),
          }),
          new NodePolyfillPlugin(),
        ],
      };
    },
  };
};

However, I have not been able to solve the last error:

Attempted import error: 'fileURLToPath' is not exported from 'url' (imported as 'fileURLToPath').
error Command failed with exit code 1.

Steps to reproduce:

  1. Download tinasaurus project
  2. Configure it with the setup given above
  3. run yarn build

Do you guys have any idea? Please, let me know if you need more info. Thanks

juliolugo96 avatar Jan 15 '24 06:01 juliolugo96