Skip to content

Commit

Permalink
chore: update rollup plugins and babel (#1610)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeetiss committed Dec 18, 2021
1 parent a592e99 commit 4c5d527
Show file tree
Hide file tree
Showing 11 changed files with 1,080 additions and 759 deletions.
11 changes: 11 additions & 0 deletions .changeset/little-emus-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@react-pdf/font': minor
'@react-pdf/fontkit': minor
'@react-pdf/image': minor
'@react-pdf/pdfkit': minor
'@react-pdf/png-js': minor
'@react-pdf/renderer': minor
'@react-pdf/unicode-properties': minor
---

updated rollup rollup-plugins and babel
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
plugins: [
'@babel/plugin-transform-runtime',
['@babel/plugin-proposal-decorators', { legacy: true }],
'@babel/plugin-proposal-class-properties',
['@babel/plugin-proposal-class-properties', { loose: true }],
'@babel/plugin-proposal-optional-chaining',
],
};
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,23 @@
"release": "changeset publish"
},
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.9.6",
"@babel/node": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.13.0",
"@babel/plugin-proposal-decorators": "^7.13.15",
"@babel/plugin-proposal-optional-chaining": "^7.9.0",
"@babel/plugin-transform-runtime": "^7.2.0",
"@babel/preset-env": "^7.9.6",
"@babel/preset-react": "^7.0.0",
"@babel/cli": "^7.16.0",
"@babel/core": "^7.16.0",
"@babel/node": "^7.16.0",
"@babel/plugin-proposal-class-properties": "^7.16.0",
"@babel/plugin-proposal-decorators": "^7.16.4",
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
"@babel/plugin-transform-runtime": "^7.16.4",
"@babel/preset-env": "^7.16.4",
"@babel/preset-react": "^7.16.0",
"@changesets/changelog-github": "^0.4.1",
"@changesets/cli": "^2.17.0",
"@rollup/plugin-alias": "^3.1.8",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^18.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.6",
"@rollup/plugin-replace": "^3.0.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.1.0",
"babel-plugin-add-module-exports": "^1.0.0",
Expand All @@ -61,16 +66,11 @@
"react": "^16.8.6",
"react-dom": "^16.8.6",
"rimraf": "^2.6.3",
"rollup": "^2.3.4",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-bundle-size": "^1.0.3",
"rollup-plugin-ignore": "^1.0.5",
"rollup-plugin-json": "^3.1.0",
"rollup": "^2.60.1",
"rollup-plugin-ignore": "^1.0.10",
"rollup-plugin-local-resolve": "^1.0.7",
"rollup-plugin-node-resolve": "^4.0.1",
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-terser": "^4.0.4"
"rollup-plugin-sourcemaps": "^0.6.3",
"rollup-plugin-terser": "^7.0.2"
},
"lint-staged": {
"*.js": [
Expand Down
18 changes: 11 additions & 7 deletions packages/font/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import babel from 'rollup-plugin-babel';
import replace from 'rollup-plugin-replace';
import babel from '@rollup/plugin-babel';
import replace from '@rollup/plugin-replace';
import sourceMaps from 'rollup-plugin-sourcemaps';

import pkg from './package.json';
Expand All @@ -15,20 +15,21 @@ const external = [
const babelConfig = ({ browser }) => ({
babelrc: false,
exclude: 'node_modules/**',
runtimeHelpers: true,
babelHelpers: 'runtime',
presets: [
[
'@babel/preset-env',
{
loose: true,
modules: false,
...(browser ? {} : { targets: { node: '8.11.3' } }),
...(browser
? { targets: { browsers: 'last 2 versions' } }
: { targets: { node: '12' } }),
},
],
'@babel/preset-react',
],
plugins: [
'@babel/plugin-transform-runtime',
['@babel/plugin-transform-runtime', { version: '^7.16.4' }],
['@babel/plugin-proposal-class-properties', { loose: true }],
],
});
Expand All @@ -37,7 +38,10 @@ const getPlugins = ({ browser }) => [
sourceMaps(),
babel(babelConfig({ browser })),
replace({
BROWSER: JSON.stringify(browser),
preventAssignment: true,
values: {
BROWSER: JSON.stringify(browser),
},
}),
];

Expand Down
28 changes: 21 additions & 7 deletions packages/fontkit/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json from 'rollup-plugin-json';
import babel from 'rollup-plugin-babel';
import json from '@rollup/plugin-json';
import babel from '@rollup/plugin-babel';
import replace from '@rollup/plugin-replace';
import ignore from 'rollup-plugin-ignore';
import replace from 'rollup-plugin-replace';
import { terser } from 'rollup-plugin-terser';
import localResolve from 'rollup-plugin-local-resolve';
import pkg from './package.json';
Expand All @@ -21,7 +21,7 @@ const getESM = override => Object.assign({}, es, override);
const babelConfig = ({ browser }) => ({
babelrc: false,
exclude: 'node_modules/**',
runtimeHelpers: true,
babelHelpers: 'runtime',
presets: [
[
'@babel/preset-env',
Expand All @@ -34,12 +34,20 @@ const babelConfig = ({ browser }) => ({
},
],
],
plugins: [['@babel/plugin-transform-runtime', { version: '^7.16.4' }]],
});

const configBase = {
input: 'src/index.js',
plugins: [localResolve(), json()],
external: ['restructure/src/utils'].concat(Object.keys(pkg.dependencies)),
external: Object.keys(pkg.dependencies).concat(
'restructure/src/utils',
'@babel/runtime/helpers/createForOfIteratorHelperLoose',
'@babel/runtime/helpers/createClass',
'@babel/runtime/helpers/applyDecoratedDescriptor',
'@babel/runtime/helpers/inheritsLoose',
'@babel/runtime/helpers/defineProperty',
),
};

const serverConfig = Object.assign({}, configBase, {
Expand All @@ -50,7 +58,10 @@ const serverConfig = Object.assign({}, configBase, {
plugins: configBase.plugins.concat(
babel(babelConfig({ browser: false })),
replace({
BROWSER: JSON.stringify(false),
preventAssignment: true,
values: {
BROWSER: JSON.stringify(false),
},
}),
),
external: configBase.external.concat(['fs', 'brotli/decompress']),
Expand All @@ -72,7 +83,10 @@ const browserConfig = Object.assign({}, configBase, {
plugins: configBase.plugins.concat(
babel(babelConfig({ browser: true })),
replace({
BROWSER: JSON.stringify(true),
preventAssignment: true,
values: {
BROWSER: JSON.stringify(true),
},
}),
ignore(['fs', 'brotli', 'brotli/decompress', './WOFF2Font']),
),
Expand Down
28 changes: 16 additions & 12 deletions packages/image/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
import babel from 'rollup-plugin-babel';
import babel from '@rollup/plugin-babel';
import replace from '@rollup/plugin-replace';
import ignore from 'rollup-plugin-ignore';
import replace from 'rollup-plugin-replace';
import sourceMaps from 'rollup-plugin-sourcemaps';

import pkg from './package.json';

const external = [
'@babel/runtime/regenerator',
'@babel/runtime/helpers/extends',
'@babel/runtime/helpers/asyncToGenerator',
'@babel/runtime/helpers/objectWithoutPropertiesLoose',
'@babel/runtime/regenerator',
...Object.keys(pkg.dependencies),
];

const babelConfig = ({ browser }) => ({
babelrc: false,
exclude: 'node_modules/**',
runtimeHelpers: true,
babelHelpers: 'runtime',
presets: [
[
'@babel/preset-env',
{
loose: true,
modules: false,
...(browser ? {} : { targets: { node: '8.11.3' } }),
...(browser
? { targets: { browsers: 'last 2 versions' } }
: { targets: { node: '12' } }),
},
],
'@babel/preset-react',
],
plugins: [
'@babel/plugin-transform-runtime',
['@babel/plugin-transform-runtime', { version: '^7.16.4' }],
['@babel/plugin-proposal-class-properties', { loose: true }],
],
});
Expand All @@ -46,7 +45,10 @@ const serverConfig = {
plugins: [
sourceMaps(),
babel(babelConfig({ browser: false })),
replace({ BROWSER: JSON.stringify(false) }),
replace({
preventAssignment: true,
values: { BROWSER: JSON.stringify(false) },
}),
],
};

Expand All @@ -62,8 +64,10 @@ const browserConfig = {
plugins: [
sourceMaps(),
babel(babelConfig({ browser: true })),
replace({ BROWSER: JSON.stringify(true) }),
,
replace({
preventAssignment: true,
values: { BROWSER: JSON.stringify(true) },
}),
ignore(['fs', 'path', 'url']),
],
};
Expand Down
46 changes: 30 additions & 16 deletions packages/pdfkit/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import babel from 'rollup-plugin-babel';
import json from 'rollup-plugin-json';
import nodeResolve from 'rollup-plugin-node-resolve';
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 replace from 'rollup-plugin-replace';
import ignore from 'rollup-plugin-ignore';

import pkg from './package.json';
Expand All @@ -22,7 +22,7 @@ const getESM = override => Object.assign({}, esm, override);
const babelConfig = ({ browser }) => ({
babelrc: false,
exclude: 'node_modules/**',
runtimeHelpers: true,
babelHelpers: 'runtime',
presets: [
[
'@babel/preset-env',
Expand All @@ -34,15 +34,23 @@ const babelConfig = ({ browser }) => ({
: { targets: { node: '12' } })
}
]
]
],
plugins: [['@babel/plugin-transform-runtime', { version: '^7.16.4' }]]
});

const configBase = {
input: 'src/index.js',
plugins: [nodeResolve(), json()],
external: Object.keys(pkg.dependencies).map(dep =>
dep === 'crypto-js' ? 'crypto-js/md5' : dep
),
plugins: [json(), nodeResolve()],
external: Object.keys(pkg.dependencies)
.map(dep => (dep === 'crypto-js' ? 'crypto-js/md5' : dep))
.concat(
'@babel/runtime/helpers/inheritsLoose',
'@babel/runtime/helpers/assertThisInitialized',
'@babel/runtime/helpers/createForOfIteratorHelperLoose',
'@babel/runtime/helpers/extends',
'stream',
'zlib'
),
onwarn: (warning, rollupWarn) => {
if (warning.code !== 'CIRCULAR_DEPENDENCY') {
rollupWarn(warning);
Expand All @@ -56,10 +64,13 @@ const serverConfig = Object.assign({}, configBase, {
getCJS({ file: 'lib/pdfkit.cjs.js' })
],
plugins: configBase.plugins.concat(
babel(babelConfig({ browser: false })),
replace({
BROWSER: JSON.stringify(false)
})
preventAssignment: true,
values: {
BROWSER: JSON.stringify(false)
}
}),
babel(babelConfig({ browser: false }))
),
external: configBase.external.concat(['fs'])
});
Expand All @@ -78,11 +89,14 @@ const browserConfig = Object.assign({}, configBase, {
getCJS({ file: 'lib/pdfkit.browser.cjs.js' })
],
plugins: configBase.plugins.concat(
babel(babelConfig({ browser: true })),
ignore(['fs']),
replace({
BROWSER: JSON.stringify(true)
preventAssignment: true,
values: {
BROWSER: JSON.stringify(true)
}
}),
ignore(['fs'])
babel(babelConfig({ browser: true }))
)
});

Expand Down
20 changes: 14 additions & 6 deletions packages/png-js/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import babel from 'rollup-plugin-babel';
import babel from '@rollup/plugin-babel';
import replace from '@rollup/plugin-replace';
import ignore from 'rollup-plugin-ignore';
import replace from 'rollup-plugin-replace';
import { terser } from 'rollup-plugin-terser';

const cjs = {
Expand All @@ -17,10 +17,11 @@ const getESM = override => Object.assign({}, esm, override);

const configBase = {
input: 'src/index.js',
external: ['zlib'],
plugins: [
babel({
babelrc: false,
runtimeHelpers: true,
babelHelpers: 'runtime',
exclude: 'node_modules/**',
presets: [
[
Expand All @@ -32,6 +33,7 @@ const configBase = {
},
],
],
plugins: [['@babel/plugin-transform-runtime', { version: '^7.16.4' }]],
}),
],
};
Expand All @@ -43,7 +45,10 @@ const serverConfig = Object.assign({}, configBase, {
],
plugins: configBase.plugins.concat(
replace({
BROWSER: JSON.stringify(false),
preventAssignment: true,
values: {
BROWSER: JSON.stringify(false),
},
}),
),
external: ['fs'],
Expand All @@ -64,8 +69,11 @@ const browserConfig = Object.assign({}, configBase, {
],
plugins: configBase.plugins.concat(
replace({
BROWSER: JSON.stringify(true),
'png-js': 'png-js/png.js',
preventAssignment: true,
values: {
BROWSER: JSON.stringify(true),
'png-js': 'png-js/png.js',
},
}),
ignore(['fs']),
),
Expand Down

0 comments on commit 4c5d527

Please sign in to comment.