diff --git a/package-lock.json b/package-lock.json index e2a7885..20278d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -73,6 +73,7 @@ "rollup-plugin-dts": "^5.1.1", "rollup-plugin-polyfill-node": "^0.11.0", "rollup-plugin-postcss": "^4.0.2", + "rollup-plugin-preserve-directives": "^0.2.0", "sass": "^1.57.1", "sass-loader": "^13.2.0", "storybook": "^7.6.4", @@ -19011,6 +19012,36 @@ "node": ">=8" } }, + "node_modules/rollup-plugin-preserve-directives": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-preserve-directives/-/rollup-plugin-preserve-directives-0.2.0.tgz", + "integrity": "sha512-KUwbBaFvD1zFIDNnOkR+u64sSod3m0l6q46/SzTOa4GTQ6hp6w0FRr2u7x99YkY9qhlna5panmTmuLWeJ/2KWw==", + "dev": true, + "dependencies": { + "magic-string": "^0.30.0" + }, + "peerDependencies": { + "rollup": "2.x || 3.x" + } + }, + "node_modules/rollup-plugin-preserve-directives/node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "dev": true + }, + "node_modules/rollup-plugin-preserve-directives/node_modules/magic-string": { + "version": "0.30.5", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.5.tgz", + "integrity": "sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==", + "dev": true, + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.15" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/rollup-pluginutils": { "version": "2.8.2", "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", diff --git a/package.json b/package.json index 2516d29..0c41366 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chaya-editor", - "version": "1.0.0-beta.1", + "version": "1.0.0-beta.2", "description": "A powerful and flexible text editor for React, built with Tiptap.", "scripts": { "tailwind": "tailwindcss -i ./src/style.scss -o ./dist/style.css -c ./tailwind.config.cjs", @@ -84,6 +84,7 @@ "rollup-plugin-dts": "^5.1.1", "rollup-plugin-polyfill-node": "^0.11.0", "rollup-plugin-postcss": "^4.0.2", + "rollup-plugin-preserve-directives": "^0.2.0", "sass": "^1.57.1", "sass-loader": "^13.2.0", "storybook": "^7.6.4", @@ -96,12 +97,6 @@ "react": "^18.2.0", "react-dom": "^18.2.0" }, - "main": "dist/cjs/index.js", - "module": "dist/esm/index.js", - "files": [ - "dist" - ], - "types": "dist/index.d.ts", "dependencies": { "@docs.plus/extension-hyperlink": "^1.5.2", "@tiptap/extension-color": "^2.1.13", @@ -115,5 +110,10 @@ "@tiptap/extension-text-style": "^2.1.13", "@tiptap/suggestion": "^2.1.13", "chaya-ui": "1.0.0-beta.74" - } + }, + "files": [ + "dist" + ], + "module": "dist/src/index.js", + "types": "dist/types/index.d.ts" } diff --git a/rollup.config.mjs b/rollup.config.mjs index fb89d6a..0579fc1 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -2,25 +2,21 @@ import resolve from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; import typescript from '@rollup/plugin-typescript'; import terser from '@rollup/plugin-terser'; -import json from '@rollup/plugin-json'; +import preserveDirectives from "rollup-plugin-preserve-directives"; import dts from 'rollup-plugin-dts'; import postcss from 'rollup-plugin-postcss'; import nodePolyfills from 'rollup-plugin-polyfill-node'; -import packageJson from './package.json' assert { type: 'json' }; - export default [ { input: 'src/index.ts', output: [ { - file: packageJson.main, - format: 'cjs', - }, - { - file: packageJson.module, - format: 'esm', + dir: 'dist', + preserveModules: true, + exports: 'named', + entryFileNames: '[name].js', }, ], plugins: [ @@ -33,17 +29,18 @@ export default [ postcss({ modules: true, minimize: true, - }), terser(), nodePolyfills(), - json(), + preserveDirectives({ + supressPreserveModulesWarning: true, + }), ], - external: ["react", "react-dom"] + external: ["react", "react-dom", "nanoid"] }, { - input: 'dist/esm/types/index.d.ts', - output: [{ file: 'dist/index.d.ts', format: 'esm' }], + input: 'dist/types/index.d.ts', + output: [{ dir: 'dist', format: 'esm' }], plugins: [dts()], }, ]; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 961a444..659d97a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,11 +8,15 @@ "jsx": "react", "module": "esnext", "declaration": true, - "declarationDir": "types", + "declarationDir": "dist/types", "sourceMap": true, "outDir": "dist", "moduleResolution": "node", "allowSyntheticDefaultImports": true, "emitDeclarationOnly": true, + "typeRoots": [ + "src/types", + "node_modules/@types" + ] } } \ No newline at end of file