Skip to content

Commit

Permalink
feat(next): added new import for nextjs with ssr disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
egordidenko committed Sep 25, 2024
1 parent 486c9c6 commit 42e956f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 10 deletions.
14 changes: 9 additions & 5 deletions packages/react-uploader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"version": "1.0.0",
"private": false,
"type": "module",
"files": [
"dist"
],
"files": ["dist"],
"main": "./dist/react-uploader.cjs",
"module": "./dist/react-uploader.js",
"types": "./dist/react-uploader.d.ts",
Expand All @@ -15,7 +13,12 @@
"import": "./dist/react-uploader.js",
"require": "./dist/react-uploader.cjs"
},
"./core.css": "./dist/libs.css"
"./next": {
"import": "./dist/nextjs.js",
"require": "./dist/nextjs.cjs",
"types": "./dist/nextjs.d.ts"
},
"./core.css": "./dist/style.css"
},
"scripts": {
"dev": "tsc && vite build --watch",
Expand All @@ -24,7 +27,8 @@
"test": "vitest"
},
"peerDependencies": {
"@types/react": "17 || 18"
"@types/react": "17 || 18",
"next": "13 || 14"
},
"dependencies": {
"@uploadcare/file-uploader": "^1.2.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import dynamic from "next/dynamic";

export const FileUploaderInline = dynamic(
() => import("./FileUploaderInline").then((mod) => mod.FileUploaderInline),
{ ssr: false },
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import dynamic from "next/dynamic";

export const FileUploaderMinimal = dynamic(
() => import("./FileUploaderMinimal").then((mod) => mod.FileUploaderMinimal),
{ ssr: false },
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import dynamic from "next/dynamic";

export const FileUploaderRegular = dynamic(
() => import("./FileUploaderRegular").then((mod) => mod.FileUploaderRegular),
{ ssr: false },
);
3 changes: 3 additions & 0 deletions packages/react-uploader/src/nextjs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { FileUploaderMinimal } from "./Uploader/Minimal/NextFileUploaderMinimal";
export { FileUploaderRegular } from "./Uploader/Regular/NextFileUploaderRegular";
export { FileUploaderInline } from "./Uploader/Inline/NextFileUploaderInline";
13 changes: 8 additions & 5 deletions packages/react-uploader/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@ import dts from "vite-plugin-dts";

export default defineConfig({
build: {
cssCodeSplit: true,
cssCodeSplit: false,
lib: {
entry: [resolve(__dirname, "src/libs.ts")],
entry: {
nextjs: resolve(__dirname, "src/nextjs.ts"),
"react-uploader": resolve(__dirname, "src/libs.ts"),
},

name: "@uploadcare/react-uploader",

formats: ["es", "cjs"],

fileName: "react-uploader",
},
rollupOptions: {
external: ["react", "@uploadcare/file-uploader"],
external: ["react", "next", "next/dynamic", "@uploadcare/file-uploader"],
output: {
globals: {
react: "React",
next: "next",
},
},
},
Expand Down

0 comments on commit 42e956f

Please sign in to comment.