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

feat!: drop cjs support #2871

Merged
merged 1 commit into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .changeset/strong-rockets-fix.md
Original file line number Diff line number Diff line change
@@ -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
10 changes: 1 addition & 9 deletions packages/fns/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@
"author": "Diego Muracciole <diegomuracciole@gmail.com>",
"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",
Expand Down
17 changes: 3 additions & 14 deletions packages/fns/rollup.config.js
Original file line number Diff line number Diff line change
@@ -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 = () => [
Expand All @@ -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(),
};
Expand Down
13 changes: 2 additions & 11 deletions packages/font/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 2 additions & 18 deletions packages/font/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/**',
Expand All @@ -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 }),
};
Expand Down
11 changes: 1 addition & 10 deletions packages/image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,10 @@
"author": "Diego Muracciole <diegomuracciole@gmail.com>",
"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",
Expand Down
20 changes: 2 additions & 18 deletions packages/image/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => ({
Expand Down Expand Up @@ -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 }),
};
Expand Down
10 changes: 1 addition & 9 deletions packages/layout/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@
"author": "Diego Muracciole <diegomuracciole@gmail.com>",
"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",
Expand Down
20 changes: 2 additions & 18 deletions packages/layout/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/,
Expand All @@ -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;
13 changes: 2 additions & 11 deletions packages/pdfkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
49 changes: 3 additions & 46 deletions packages/pdfkit/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,13 @@ 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';
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 = () => ({
Expand All @@ -43,7 +29,7 @@ const getExternal = ({ browser }) => [
...(browser ? [] : ['fs'])
];

const getPlugins = ({ browser, minify = false }) => [
const getPlugins = ({ browser }) => [
json(),
...(browser
? [
Expand Down Expand Up @@ -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
];
13 changes: 2 additions & 11 deletions packages/png-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading