diff --git a/.changeset/strong-rockets-fix.md b/.changeset/strong-rockets-fix.md new file mode 100644 index 000000000..df3020b36 --- /dev/null +++ b/.changeset/strong-rockets-fix.md @@ -0,0 +1,15 @@ +--- +"@react-pdf/primitives": major +"@react-pdf/stylesheet": major +"@react-pdf/renderer": major +"@react-pdf/textkit": major +"@react-pdf/layout": major +"@react-pdf/pdfkit": major +"@react-pdf/png-js": major +"@react-pdf/render": major +"@react-pdf/image": major +"@react-pdf/font": major +"@react-pdf/fns": major +--- + +feat!: drop cjs support diff --git a/packages/fns/package.json b/packages/fns/package.json index 2b733ec7e..8e675ecfc 100644 --- a/packages/fns/package.json +++ b/packages/fns/package.json @@ -6,15 +6,7 @@ "author": "Diego Muracciole ", "homepage": "https://github.com/diegomura/react-pdf#readme", "type": "module", - "main": "./lib/index.cjs", - "module": "./lib/index.js", - "exports": { - ".": { - "import": "./lib/index.js", - "require": "./lib/index.cjs", - "default": "./lib/index.js" - } - }, + "main": "./lib/index.js", "repository": { "type": "git", "url": "https://github.com/diegomura/react-pdf.git", diff --git a/packages/fns/rollup.config.js b/packages/fns/rollup.config.js index d1188600d..7382d5861 100644 --- a/packages/fns/rollup.config.js +++ b/packages/fns/rollup.config.js @@ -1,20 +1,9 @@ import babel from '@rollup/plugin-babel'; -const cjs = { - exports: 'named', - format: 'cjs', - interop: 'compat', -}; - -const esm = { - format: 'es', -}; - -const getCJS = (override) => Object.assign({}, cjs, override); -const getESM = (override) => Object.assign({}, esm, override); - const input = 'src/index.js'; +const output = { format: 'es', file: 'lib/index.js' }; + const getExternal = () => [/@babel\/runtime/]; const getPlugins = () => [ @@ -27,7 +16,7 @@ const getPlugins = () => [ const config = { input, - output: [getESM({ file: 'lib/index.js' }), getCJS({ file: 'lib/index.cjs' })], + output, external: getExternal(), plugins: getPlugins(), }; diff --git a/packages/font/package.json b/packages/font/package.json index faf430922..4c5967396 100644 --- a/packages/font/package.json +++ b/packages/font/package.json @@ -11,18 +11,9 @@ "directory": "packages/font" }, "type": "module", - "main": "./lib/index.cjs", - "module": "./lib/index.js", + "main": "./lib/index.js", "browser": { - "./lib/index.js": "./lib/index.browser.js", - "./lib/index.cjs": "./lib/index.browser.cjs" - }, - "exports": { - ".": { - "import": "./lib/index.js", - "require": "./lib/index.cjs", - "default": "./lib/index.js" - } + "./lib/index.js": "./lib/index.browser.js" }, "scripts": { "test": "vitest", diff --git a/packages/font/rollup.config.js b/packages/font/rollup.config.js index 8383cd4a8..c77d10821 100644 --- a/packages/font/rollup.config.js +++ b/packages/font/rollup.config.js @@ -2,19 +2,6 @@ import babel from '@rollup/plugin-babel'; import replace from '@rollup/plugin-replace'; import pkg from './package.json' assert { type: 'json' }; -const cjs = { - exports: 'named', - format: 'cjs', - interop: 'compat', -}; - -const esm = { - format: 'es', -}; - -const getCJS = (override) => Object.assign({}, cjs, override); -const getESM = (override) => Object.assign({}, esm, override); - const babelConfig = () => ({ babelrc: true, exclude: 'node_modules/**', @@ -35,17 +22,14 @@ const getPlugins = ({ browser }) => [ const serverConfig = { input: './src/index.js', - output: [getESM({ file: 'lib/index.js' }), getCJS({ file: 'lib/index.cjs' })], + output: { format: 'es', file: 'lib/index.js' }, external, plugins: getPlugins({ browser: false }), }; const browserConfig = { input: './src/index.js', - output: [ - getESM({ file: 'lib/index.browser.js' }), - getCJS({ file: 'lib/index.browser.cjs' }), - ], + output: { format: 'es', file: 'lib/index.browser.js' }, external, plugins: getPlugins({ browser: true }), }; diff --git a/packages/image/package.json b/packages/image/package.json index da50039fc..0c69ca4be 100644 --- a/packages/image/package.json +++ b/packages/image/package.json @@ -6,19 +6,10 @@ "author": "Diego Muracciole ", "homepage": "https://github.com/diegomura/react-pdf#readme", "type": "module", - "main": "./lib/index.cjs", - "module": "./lib/index.js", + "main": "./lib/index.js", "browser": { - "./lib/index.cjs": "./lib/index.browser.cjs", "./lib/index.js": "./lib/index.browser.js" }, - "exports": { - ".": { - "import": "./lib/index.js", - "require": "./lib/index.cjs", - "default": "./lib/index.js" - } - }, "repository": { "type": "git", "url": "https://github.com/diegomura/react-pdf.git", diff --git a/packages/image/rollup.config.js b/packages/image/rollup.config.js index 878073a54..2822f026f 100644 --- a/packages/image/rollup.config.js +++ b/packages/image/rollup.config.js @@ -5,19 +5,6 @@ import nodePolyfills from 'rollup-plugin-polyfill-node'; import pkg from './package.json' assert { type: 'json' }; -const cjs = { - exports: 'named', - format: 'cjs', - interop: 'compat', -}; - -const esm = { - format: 'es', -}; - -const getCJS = (override) => Object.assign({}, cjs, override); -const getESM = (override) => Object.assign({}, esm, override); - const input = './src/index.js'; const babelConfig = () => ({ @@ -50,17 +37,14 @@ const getPlugins = ({ browser }) => [ const serverConfig = { input, - output: [getESM({ file: 'lib/index.js' }), getCJS({ file: 'lib/index.cjs' })], + output: { format: 'es', file: 'lib/index.js' }, external: getExternal({ browser: false }), plugins: getPlugins({ browser: false }), }; const browserConfig = { input, - output: [ - getESM({ file: 'lib/index.browser.js' }), - getCJS({ file: 'lib/index.browser.cjs' }), - ], + output: { format: 'es', file: 'lib/index.browser.js' }, external: getExternal({ browser: true }), plugins: getPlugins({ browser: true }), }; diff --git a/packages/layout/package.json b/packages/layout/package.json index 5841ad4ee..a39ad07a2 100644 --- a/packages/layout/package.json +++ b/packages/layout/package.json @@ -6,15 +6,7 @@ "author": "Diego Muracciole ", "homepage": "https://github.com/diegomura/react-pdf#readme", "type": "module", - "main": "./lib/index.cjs", - "module": "./lib/index.js", - "exports": { - ".": { - "import": "./lib/index.js", - "require": "./lib/index.cjs", - "default": "./lib/index.js" - } - }, + "main": "./lib/index.js", "repository": { "type": "git", "url": "https://github.com/diegomura/react-pdf.git", diff --git a/packages/layout/rollup.config.js b/packages/layout/rollup.config.js index 849ee121b..9f1ba6640 100644 --- a/packages/layout/rollup.config.js +++ b/packages/layout/rollup.config.js @@ -2,21 +2,9 @@ import babel from '@rollup/plugin-babel'; import pkg from './package.json' assert { type: 'json' }; -const cjs = { - exports: 'named', - format: 'cjs', - interop: 'compat', -}; - -const esm = { - format: 'es', -}; - -const getCJS = (override) => Object.assign({}, cjs, override); -const getESM = (override) => Object.assign({}, esm, override); - -const configBase = { +const config = { input: 'src/index.js', + output: { format: 'es', file: 'lib/index.js' }, external: Object.keys(pkg.dependencies).concat( /@babel\/runtime/, /@react-pdf/, @@ -30,8 +18,4 @@ const configBase = { ], }; -const config = Object.assign({}, configBase, { - output: [getESM({ file: 'lib/index.js' }), getCJS({ file: 'lib/index.cjs' })], -}); - export default config; diff --git a/packages/pdfkit/package.json b/packages/pdfkit/package.json index a84ed1845..177b5999e 100644 --- a/packages/pdfkit/package.json +++ b/packages/pdfkit/package.json @@ -4,18 +4,9 @@ "license": "MIT", "description": "A PDF generation library for Node.js", "type": "module", - "main": "./lib/pdfkit.cjs", - "module": "./lib/pdfkit.js", + "main": "./lib/pdfkit.js", "browser": { - "./lib/pdfkit.js": "./lib/pdfkit.browser.js", - "./lib/pdfkit.cjs": "./lib/pdfkit.browser.cjs" - }, - "exports": { - ".": { - "import": "./lib/pdfkit.js", - "require": "./lib/pdfkit.cjs", - "default": "./lib/pdfkit.js" - } + "./lib/pdfkit.js": "./lib/pdfkit.browser.js" }, "repository": { "type": "git", diff --git a/packages/pdfkit/rollup.config.js b/packages/pdfkit/rollup.config.js index 99689e820..63cb264cf 100644 --- a/packages/pdfkit/rollup.config.js +++ b/packages/pdfkit/rollup.config.js @@ -2,7 +2,6 @@ import babel from '@rollup/plugin-babel'; import json from '@rollup/plugin-json'; import replace from '@rollup/plugin-replace'; import nodeResolve from '@rollup/plugin-node-resolve'; -import terser from '@rollup/plugin-terser'; import ignore from 'rollup-plugin-ignore'; import alias from '@rollup/plugin-alias'; import nodePolyfills from 'rollup-plugin-polyfill-node'; @@ -10,19 +9,6 @@ import commonjs from '@rollup/plugin-commonjs'; import pkg from './package.json' assert { type: 'json' }; -const cjs = { - exports: 'named', - format: 'cjs', - interop: 'compat' -}; - -const esm = { - format: 'es' -}; - -const getCJS = (override) => Object.assign({}, cjs, override); -const getESM = (override) => Object.assign({}, esm, override); - const input = 'src/index.js'; const babelConfig = () => ({ @@ -43,7 +29,7 @@ const getExternal = ({ browser }) => [ ...(browser ? [] : ['fs']) ]; -const getPlugins = ({ browser, minify = false }) => [ +const getPlugins = ({ browser }) => [ json(), ...(browser ? [ @@ -77,52 +63,23 @@ const getPlugins = ({ browser, minify = false }) => [ } }), babel(babelConfig()), - ...(minify ? [terser()] : []) ]; const serverConfig = { input, - output: [ - getESM({ file: 'lib/pdfkit.js' }), - getCJS({ file: 'lib/pdfkit.cjs' }) - ], + output: { format: 'es', file: 'lib/pdfkit.js' }, external: getExternal({ browser: false }), plugins: getPlugins({ browser: false }) }; -const serverProdConfig = { - input, - output: [ - getESM({ file: 'lib/pdfkit.min.js' }), - getCJS({ file: 'lib/pdfkit.min.cjs' }) - ], - external: getExternal({ browser: false }), - plugins: getPlugins({ browser: false, minify: true }) -}; - const browserConfig = { input, - output: [ - getESM({ file: 'lib/pdfkit.browser.js' }), - getCJS({ file: 'lib/pdfkit.browser.cjs' }) - ], + output: { format: 'es', file: 'lib/pdfkit.browser.js' }, external: getExternal({ browser: true }), plugins: getPlugins({ browser: true }) }; -const browserProdConfig = Object.assign({}, browserConfig, { - input, - output: [ - getESM({ file: 'lib/pdfkit.browser.min.js' }), - getCJS({ file: 'lib/pdfkit.browser.min.cjs' }) - ], - external: getExternal({ browser: true }), - plugins: getPlugins({ browser: true, minify: true }) -}); - export default [ serverConfig, - serverProdConfig, browserConfig, - browserProdConfig ]; diff --git a/packages/png-js/package.json b/packages/png-js/package.json index 11d4cf6d9..aaa0692b4 100644 --- a/packages/png-js/package.json +++ b/packages/png-js/package.json @@ -4,18 +4,9 @@ "version": "2.3.1", "license": "MIT", "type": "module", - "main": "./lib/png-js.cjs", - "module": "./lib/png-js.js", + "main": "./lib/png-js.js", "browser": { - "./lib/png-js.js": "./lib/png-js.browser.js", - "./lib/png-js.cjs": "./lib/png-js.browser.cjs" - }, - "exports": { - ".": { - "import": "./lib/png-js.js", - "require": "./lib/png-js.cjs", - "default": "./lib/png-js.js" - } + "./lib/png-js.js": "./lib/png-js.browser.js" }, "repository": { "type": "git", diff --git a/packages/png-js/rollup.config.js b/packages/png-js/rollup.config.js index 97c4f5153..b6d1d7aa6 100644 --- a/packages/png-js/rollup.config.js +++ b/packages/png-js/rollup.config.js @@ -8,19 +8,6 @@ import commonjs from '@rollup/plugin-commonjs'; import pkg from './package.json' assert { type: 'json' }; -const cjs = { - exports: 'named', - format: 'cjs', - interop: 'compat', -}; - -const esm = { - format: 'es', -}; - -const getCJS = (override) => Object.assign({}, cjs, override); -const getESM = (override) => Object.assign({}, esm, override); - const input = 'src/index.js'; const babelConfig = () => ({ @@ -63,20 +50,14 @@ const getPlugins = ({ browser }) => [ const serverConfig = { input, - output: [ - getESM({ file: 'lib/png-js.js' }), - getCJS({ file: 'lib/png-js.cjs' }), - ], + output: { format: 'es', file: 'lib/png-js.js' }, external: getExternal({ browser: false }), plugins: getPlugins({ browser: false }), }; const browserConfig = { input, - output: [ - getESM({ file: 'lib/png-js.browser.js' }), - getCJS({ file: 'lib/png-js.browser.cjs' }), - ], + output: { format: 'es', file: 'lib/png-js.browser.js' }, external: getExternal({ browser: true }), plugins: getPlugins({ browser: true }), }; diff --git a/packages/primitives/package.json b/packages/primitives/package.json index b2c95a773..02cfb6b2a 100644 --- a/packages/primitives/package.json +++ b/packages/primitives/package.json @@ -6,22 +6,13 @@ "author": "Diego Muracciole ", "homepage": "https://github.com/diegomura/react-pdf#readme", "type": "module", - "main": "./lib/index.cjs", - "module": "./src/index.js", - "exports": { - ".": { - "import": "./src/index.js", - "require": "./lib/index.cjs", - "default": "./src/index.js" - } - }, + "main": "./src/index.js", "repository": { "type": "git", "url": "https://github.com/diegomura/react-pdf.git", "directory": "packages/primitives" }, "scripts": { - "build": "babel src --out-dir lib && mv lib/index.js lib/index.cjs", "test": "vitest" }, "files": [ diff --git a/packages/render/package.json b/packages/render/package.json index 3b0e1b180..c46a07600 100644 --- a/packages/render/package.json +++ b/packages/render/package.json @@ -6,15 +6,7 @@ "author": "Diego Muracciole ", "homepage": "https://github.com/diegomura/react-pdf#readme", "type": "module", - "main": "./lib/index.cjs", - "module": "./lib/index.js", - "exports": { - ".": { - "import": "./lib/index.js", - "require": "./lib/index.cjs", - "default": "./lib/index.js" - } - }, + "main": "./lib/index.js", "repository": { "type": "git", "url": "https://github.com/diegomura/react-pdf.git", diff --git a/packages/render/rollup.config.js b/packages/render/rollup.config.js index 5721534f1..da5cd8847 100644 --- a/packages/render/rollup.config.js +++ b/packages/render/rollup.config.js @@ -3,21 +3,9 @@ import babel from '@rollup/plugin-babel'; import pkg from './package.json' assert { type: 'json' }; -const cjs = { - exports: 'named', - format: 'cjs', - interop: 'compat', -}; - -const esm = { - format: 'es', -}; - -const getCJS = (override) => Object.assign({}, cjs, override); -const getESM = (override) => Object.assign({}, esm, override); - -const configBase = { +const config = { input: 'src/index.js', + output: { format: 'es', file: 'lib/index.js' }, external: Object.keys(pkg.dependencies).concat( /@babel\/runtime/, /@react-pdf/, @@ -32,8 +20,4 @@ const configBase = { ], }; -const config = Object.assign({}, configBase, { - output: [getESM({ file: 'lib/index.js' }), getCJS({ file: 'lib/index.cjs' })], -}); - export default config; diff --git a/packages/renderer/package.json b/packages/renderer/package.json index fb67ba7d6..986749ed9 100644 --- a/packages/renderer/package.json +++ b/packages/renderer/package.json @@ -6,18 +6,9 @@ "author": "Diego Muracciole ", "homepage": "https://github.com/diegomura/react-pdf#readme", "type": "module", - "main": "./lib/react-pdf.cjs", - "module": "./lib/react-pdf.js", + "main": "./lib/react-pdf.js", "browser": { - "./lib/react-pdf.js": "./lib/react-pdf.browser.js", - "./lib/react-pdf.cjs": "./lib/react-pdf.browser.cjs" - }, - "exports": { - ".": { - "import": "./lib/react-pdf.js", - "require": "./lib/react-pdf.cjs", - "default": "./lib/react-pdf.js" - } + "./lib/react-pdf.js": "./lib/react-pdf.browser.js" }, "repository": { "type": "git", diff --git a/packages/renderer/rollup.config.js b/packages/renderer/rollup.config.js index bb8abbfc1..63f3cb2c6 100644 --- a/packages/renderer/rollup.config.js +++ b/packages/renderer/rollup.config.js @@ -10,21 +10,6 @@ import copy from 'rollup-plugin-copy'; import pkg from './package.json' assert { type: 'json' }; -const cjs = { - exports: 'named', - format: 'cjs', - interop: 'compat', - sourcemap: true, -}; - -const esm = { - format: 'es', - sourcemap: true, -}; - -const getCJS = (override) => Object.assign({}, cjs, override); -const getESM = (override) => Object.assign({}, esm, override); - const nodeInput = './src/node/index.js'; const domInput = './src/dom/index.js'; @@ -76,10 +61,7 @@ const getPlugins = ({ browser, declarationDests, minify = false }) => [ const serverConfig = { input: nodeInput, - output: [ - getESM({ file: 'lib/react-pdf.js' }), - getCJS({ file: 'lib/react-pdf.cjs' }), - ], + output: { file: 'lib/react-pdf.js', format: 'es', sourcemap: true }, external: getExternal({ browser: false }), plugins: getPlugins({ browser: false, @@ -89,10 +71,7 @@ const serverConfig = { const serverProdConfig = { input: nodeInput, - output: [ - getESM({ file: 'lib/react-pdf.min.js', sourcemap: false }), - getCJS({ file: 'lib/react-pdf.min.cjs', sourcemap: false }), - ], + output: { file: 'lib/react-pdf.min.js', sourcemap: false, format: 'es' }, external: getExternal({ browser: false }), plugins: getPlugins({ browser: false, @@ -103,10 +82,7 @@ const serverProdConfig = { const browserConfig = { input: domInput, - output: [ - getESM({ file: 'lib/react-pdf.browser.js' }), - getCJS({ file: 'lib/react-pdf.browser.cjs' }), - ], + output: { file: 'lib/react-pdf.browser.js', format: 'es', sourcemap: true }, external: getExternal({ browser: true }), plugins: getPlugins({ browser: true, @@ -119,10 +95,7 @@ const browserConfig = { const browserProdConfig = { input: domInput, - output: [ - getESM({ file: 'lib/react-pdf.browser.min.js', sourcemap: false }), - getCJS({ file: 'lib/react-pdf.browser.min.cjs', sourcemap: false }), - ], + output: { file: 'lib/react-pdf.browser.min.js', format: 'es' }, external: getExternal({ browser: true }), plugins: getPlugins({ browser: true, diff --git a/packages/stylesheet/package.json b/packages/stylesheet/package.json index 78146af27..deb564c7a 100644 --- a/packages/stylesheet/package.json +++ b/packages/stylesheet/package.json @@ -6,15 +6,7 @@ "author": "Diego Muracciole ", "homepage": "https://github.com/diegomura/react-pdf#readme", "type": "module", - "main": "./lib/index.cjs", - "module": "./lib/index.js", - "exports": { - ".": { - "import": "./lib/index.js", - "require": "./lib/index.cjs", - "default": "./lib/index.js" - } - }, + "main": "./lib/index.js", "repository": { "type": "git", "url": "https://github.com/diegomura/react-pdf.git", diff --git a/packages/stylesheet/rollup.config.js b/packages/stylesheet/rollup.config.js index 18084bac0..61a4d3cc3 100644 --- a/packages/stylesheet/rollup.config.js +++ b/packages/stylesheet/rollup.config.js @@ -3,19 +3,6 @@ import babel from '@rollup/plugin-babel'; import pkg from './package.json' assert { type: 'json' }; -const cjs = { - exports: 'named', - format: 'cjs', - interop: 'compat', -}; - -const esm = { - format: 'es', -}; - -const getCJS = (override) => Object.assign({}, cjs, override); -const getESM = (override) => Object.assign({}, esm, override); - const input = 'src/index.js'; const getExternal = () => [ @@ -35,7 +22,7 @@ const getPlugins = () => [ const config = { input, - output: [getESM({ file: 'lib/index.js' }), getCJS({ file: 'lib/index.cjs' })], + output: { format: 'es', file: 'lib/index.js' }, external: getExternal(), plugins: getPlugins(), }; diff --git a/packages/textkit/package.json b/packages/textkit/package.json index 28d69e0f6..dce666431 100644 --- a/packages/textkit/package.json +++ b/packages/textkit/package.json @@ -4,15 +4,7 @@ "version": "4.4.1", "description": "An advanced text layout framework", "type": "module", - "main": "./lib/textkit.cjs", - "module": "./lib/textkit.js", - "exports": { - ".": { - "import": "./lib/textkit.js", - "require": "./lib/textkit.cjs", - "default": "./lib/textkit.js" - } - }, + "main": "./lib/textkit.js", "repository": { "type": "git", "url": "https://github.com/diegomura/react-pdf.git", diff --git a/packages/textkit/rollup.config.js b/packages/textkit/rollup.config.js index f2ec1c05b..55e8fc286 100644 --- a/packages/textkit/rollup.config.js +++ b/packages/textkit/rollup.config.js @@ -3,19 +3,6 @@ import localResolve from 'rollup-plugin-local-resolve'; import pkg from './package.json' assert { type: 'json' }; -const cjs = { - exports: 'named', - format: 'cjs', - interop: 'compat', -}; - -const esm = { - format: 'es', -}; - -const getCJS = (override) => Object.assign({}, cjs, override); -const getESM = (override) => Object.assign({}, esm, override); - const babelConfig = () => ({ babelrc: true, exclude: 'node_modules/**', @@ -34,10 +21,7 @@ const getPlugins = () => [localResolve(), babel(babelConfig())]; const config = { input, - output: [ - getESM({ file: 'lib/textkit.js' }), - getCJS({ file: 'lib/textkit.cjs' }), - ], + output: { format: 'es', file: 'lib/textkit.js' }, external: getExternal(), plugins: getPlugins(), };