Skip to content

Commit

Permalink
workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Feb 22, 2024
1 parent 1ba05a4 commit 2e370cb
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 8 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"ts-node": "^10.9.1",
"typescript": "^5.3.3",
"vike": "^0.4.162",
"vite": "^5.0.10"
"vite": "^5.0.10",
"vite-plugin-cjs-interop": "^2.0.6"
},
"type": "module",
"devDependencies": {
Expand Down
6 changes: 5 additions & 1 deletion pages/index/+Page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import ImageGallery from "react-image-gallery";
/* Manual fix:
import ImageGallery_ from "react-image-gallery";
const ImageGallery = (ImageGallery_ as any).default as typeof ImageGallery_
*/
// import stylesheet if you're not already using CSS @import
import "react-image-gallery/styles/css/image-gallery.css";

Expand Down Expand Up @@ -26,4 +30,4 @@ function Page() {
<ImageGallery items={images} />;
</>
)
}
}
25 changes: 25 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 26 additions & 6 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
import react from '@vitejs/plugin-react'
import vike from 'vike/plugin'
import { UserConfig } from 'vite'
import {cjsInterop} from "vite-plugin-cjs-interop";
import {UserConfig} from 'vite'

const config: UserConfig = {
plugins: [react(), vike()]
}

export default config
export default {
plugins: [
react(), vike(),
cjsInterop({
// List of CJS dependencies that require interop
dependencies: [
"react-image-gallery",
],
}),
],
/* Doesn't work:
ssr: {
noExternal: [
"react-image-gallery",
],
// https://github.com/vitejs/vite/issues/14158#issuecomment-1685033558
optimizeDeps: {
include: [
"react-image-gallery",
]
}
}
*/
} satisfies UserConfig;

0 comments on commit 2e370cb

Please sign in to comment.