Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken build when using mongoose - rollup plugin configuration #623

Closed
birkskyum opened this issue Jan 4, 2023 · 1 comment · Fixed by #626
Closed

Broken build when using mongoose - rollup plugin configuration #623

birkskyum opened this issue Jan 4, 2023 · 1 comment · Fixed by #626

Comments

@birkskyum
Copy link
Contributor

birkskyum commented Jan 4, 2023

I've made a reproduction here;

https://github.com/birkskyum/solid-mongoose-issue

Importing mongoose in a route like this breaks the build:

import { Title } from "solid-start";
import Counter from "~/components/Counter";
import {version} from "mongoose"

export default function Home() {
  console.log(version)
  return (
    <main>
      <Title>Hello World</Title>
      <h1>Hello world!</h1>
      <Counter />
    </main>
  );
}

The error is like this:

./dist/server.js:107060 var decimal128$3 = driver$1.get().Decimal128; ^

TypeError: Cannot read properties of null (reading 'Decimal128') at ./dist/server.js:107060:34 at ModuleJob.run (node:internal/modules/esm/module_job:193:25) at async Promise.all (index 0) at async ESMLoader.import (node:internal/modules/esm/loader:530:24)

Node.js v18.12.1

It's supposedly related to the bundling order as mentioned in this mongoose ticket. It would be interesting to see if the error persist in vite to 4 /w rollup 3.

@birkskyum
Copy link
Contributor Author

There is an escape hatch in vite config to add configuration to @rollup/plugin-commonjs, but it seems to not be working. I wonder if solid-start overwrites the rollup plugins somewhere.

import solid from "solid-start/vite";
import { defineConfig } from "vite";

export default defineConfig({
	build: {
    commonjsOptions:{
      strictRequires: true
    }
  },
	plugins: [
		solid({
			ssr: true,
		}),
	],
});

@birkskyum birkskyum changed the title Broken build when using mongoose Broken build when using mongoose - rollup plugin configuration Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant