diff --git a/.changeset/lazy-news-laugh.md b/.changeset/lazy-news-laugh.md new file mode 100644 index 000000000..cf107b6e5 --- /dev/null +++ b/.changeset/lazy-news-laugh.md @@ -0,0 +1,17 @@ +--- +'@react-pdf/primitives': minor +'@react-pdf/stylesheet': minor +'@react-pdf/examples': minor +'@react-pdf/renderer': minor +'@react-pdf/textkit': minor +'@react-pdf/layout': minor +'@react-pdf/pdfkit': minor +'@react-pdf/png-js': minor +'@react-pdf/render': minor +'@react-pdf/svgkit': minor +'@react-pdf/image': minor +'@react-pdf/font': minor +'@react-pdf/fns': minor +--- + +Add support for native ESM diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 1e0c70eb3..000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,45 +0,0 @@ -module.exports = { - parser: 'babel-eslint', - env: { - browser: true, - es6: true, - node: true, - 'jest/globals': true, - }, - extends: [ - 'plugin:react/recommended', - 'airbnb', - 'prettier', - 'plugin:react/jsx-runtime', - ], - globals: { - URL: false, - BROWSER: false, - Atomics: 'readonly', - SharedArrayBuffer: 'readonly', - }, - parserOptions: { - ecmaFeatures: { - jsx: true, - }, - ecmaVersion: 2018, - sourceType: 'module', - }, - plugins: ['react', 'jest'], - rules: { - 'func-names': 0, - 'no-continue': 1, - 'no-cond-assign': 1, - 'react/prop-types': 0, - 'prefer-destructuring': 1, - 'no-use-before-define': 1, - 'no-underscore-dangle': 0, - 'prefer-object-spread': 0, - 'import/no-named-as-default': 0, - 'react/state-in-constructor': 0, - 'react/jsx-filename-extension': 0, - 'react/jsx-props-no-spreading': 0, - 'react/destructuring-assignment': 0, - 'import/no-unresolved': ['error', { ignore: ['^yoga-layout'] }], - }, -}; diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 000000000..4498dcaa4 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,55 @@ +{ + "parser": "babel-eslint", + "env": { + "browser": true, + "es6": true, + "node": true + }, + "extends": [ + "plugin:react/recommended", + "airbnb", + "prettier", + "plugin:react/jsx-runtime" + ], + "globals": { + "URL": false, + "BROWSER": false, + "Atomics": "readonly", + "SharedArrayBuffer": "readonly" + }, + "parserOptions": { + "ecmaFeatures": { + "jsx": true + }, + "ecmaVersion": 2018, + "sourceType": "module" + }, + "plugins": ["react", "jest"], + "rules": { + "func-names": 0, + "no-continue": 1, + "no-cond-assign": 1, + "react/prop-types": 0, + "prefer-destructuring": 1, + "no-use-before-define": 1, + "no-underscore-dangle": 0, + "prefer-object-spread": 0, + "import/no-named-as-default": 0, + "react/state-in-constructor": 0, + "react/jsx-filename-extension": 0, + "react/jsx-props-no-spreading": 0, + "react/destructuring-assignment": 0, + "import/no-unresolved": ["error", { "ignore": ["^yoga-layout"] }] + }, + "overrides": [ + { + "files": ["**/*.test.js", "**/tests/**/*.js", "setup.jest.js"], + "env": { + "jest": true + }, + "rules": { + "import/no-extraneous-dependencies": 0 + } + } + ] +} diff --git a/babel.config.js b/babel.config.js index 285a04652..673c9482a 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,4 +1,4 @@ -module.exports = { +export default { presets: [ [ '@babel/preset-env', diff --git a/jest.config.js b/jest.config.js index 4d46d501c..c9d2b006e 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,4 +1,4 @@ -module.exports = { +export default { projects: [ 'packages/fns', 'packages/font', diff --git a/package.json b/package.json index 4e3be6eee..2f2700edc 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "license": "MIT", "author": "Diego Muracciole ", "homepage": "https://github.com/diegomura/react-pdf#readme", + "type": "module", "repository": "git@github.com:diegomura/react-pdf.git", "workspaces": [ "packages/*" @@ -16,7 +17,7 @@ "bootstrap": "lerna bootstrap", "prepublish": "lerna run build", "lint": "eslint packages", - "test": "jest", + "test": "NODE_OPTIONS=\"--experimental-vm-modules\" jest", "dev": "lerna run dev --scope @react-pdf/examples", "changeset": "changeset", "version-packages": "changeset version", @@ -25,7 +26,6 @@ "devDependencies": { "@babel/cli": "^7.20.7", "@babel/core": "^7.20.7", - "@babel/node": "^7.20.7", "@babel/plugin-proposal-class-properties": "^7.18.6", "@babel/plugin-proposal-decorators": "^7.20.13", "@babel/plugin-proposal-optional-chaining": "^7.20.7", @@ -34,6 +34,7 @@ "@babel/preset-react": "^7.18.6", "@changesets/changelog-github": "^0.4.8", "@changesets/cli": "^2.26.0", + "@jest/globals": "^29.5.0", "@rollup/plugin-alias": "^3.1.8", "@rollup/plugin-babel": "^5.3.0", "@rollup/plugin-commonjs": "^21.0.1", @@ -67,6 +68,7 @@ "react-dom": "^18.2.0", "rimraf": "^2.6.3", "rollup": "^2.60.1", + "rollup-plugin-copy": "^3.5.0", "rollup-plugin-ignore": "^1.0.10", "rollup-plugin-local-resolve": "^1.0.7", "rollup-plugin-polyfill-node": "^0.9.0", diff --git a/packages/examples/.eslintrc.js b/packages/examples/.eslintrc.js deleted file mode 100644 index 98189c96c..000000000 --- a/packages/examples/.eslintrc.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - extends: ['../../.eslintrc.js', 'plugin:react/recommended'], - rules: { - 'react/prop-types': 0, - 'jsx-a11y/anchor-is-valid': 0, - 'react/jsx-one-expression-per-line': 0, - }, -}; diff --git a/packages/examples/.eslintrc.json b/packages/examples/.eslintrc.json new file mode 100644 index 000000000..acf25ba13 --- /dev/null +++ b/packages/examples/.eslintrc.json @@ -0,0 +1,8 @@ +{ + "extends": ["../../.eslintrc.json", "plugin:react/recommended"], + "rules": { + "react/prop-types": 0, + "jsx-a11y/anchor-is-valid": 0, + "react/jsx-one-expression-per-line": 0 + } +} diff --git a/packages/fns/babel.config.js b/packages/fns/babel.config.js index 27f83582f..02d1cbbdb 100644 --- a/packages/fns/babel.config.js +++ b/packages/fns/babel.config.js @@ -1 +1 @@ -module.exports = { extends: '../../babel.config.js' }; +export default { extends: '../../babel.config.js' }; diff --git a/packages/fns/jest.config.js b/packages/fns/jest.config.js index 1a99b7295..40b1faa8e 100644 --- a/packages/fns/jest.config.js +++ b/packages/fns/jest.config.js @@ -1,3 +1,3 @@ -module.exports = { +export default { testRegex: 'tests/.*?(test)\\.js$', }; diff --git a/packages/fns/package.json b/packages/fns/package.json index 833208fc6..17a23136c 100644 --- a/packages/fns/package.json +++ b/packages/fns/package.json @@ -5,15 +5,23 @@ "description": "React-pdf helper functions", "author": "Diego Muracciole ", "homepage": "https://github.com/diegomura/react-pdf#readme", - "main": "lib/index.cjs.js", - "module": "lib/index.es.js", + "type": "module", + "main": "./lib/index.cjs", + "module": "./lib/index.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", "directory": "packages/fns" }, "scripts": { - "test": "jest", + "test": "NODE_OPTIONS=\"--experimental-vm-modules\" jest", "build": "rimraf ./lib && rollup -c", "watch": "rimraf ./lib && rollup -c -w" }, diff --git a/packages/fns/rollup.config.js b/packages/fns/rollup.config.js index 2e284f012..a8d3e9e1c 100644 --- a/packages/fns/rollup.config.js +++ b/packages/fns/rollup.config.js @@ -27,10 +27,7 @@ const getPlugins = () => [ const config = { input, - output: [ - getESM({ file: 'lib/index.es.js' }), - getCJS({ file: 'lib/index.cjs.js' }), - ], + output: [getESM({ file: 'lib/index.js' }), getCJS({ file: 'lib/index.cjs' })], external: getExternal(), plugins: getPlugins(), }; diff --git a/packages/font/babel.config.js b/packages/font/babel.config.js index 27f83582f..02d1cbbdb 100644 --- a/packages/font/babel.config.js +++ b/packages/font/babel.config.js @@ -1 +1 @@ -module.exports = { extends: '../../babel.config.js' }; +export default { extends: '../../babel.config.js' }; diff --git a/packages/font/package.json b/packages/font/package.json index c15eb6aa7..a971775d4 100644 --- a/packages/font/package.json +++ b/packages/font/package.json @@ -10,14 +10,22 @@ "url": "https://github.com/diegomura/react-pdf.git", "directory": "packages/font" }, - "main": "./lib/index.cjs.js", - "module": "./lib/index.es.js", + "type": "module", + "main": "./lib/index.cjs", + "module": "./lib/index.js", "browser": { - "./lib/index.es.js": "./lib/index.browser.es.js", - "./lib/index.cjs.js": "./lib/index.browser.cjs.js" + "./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" + } }, "scripts": { - "test": "jest", + "test": "NODE_OPTIONS=\"--experimental-vm-modules\" jest", "build": "rimraf ./lib && rollup -c", "watch": "rimraf ./lib && rollup -c -w" }, diff --git a/packages/font/rollup.config.js b/packages/font/rollup.config.js index 060df2223..4aad74012 100644 --- a/packages/font/rollup.config.js +++ b/packages/font/rollup.config.js @@ -34,10 +34,7 @@ const getPlugins = ({ browser }) => [ const serverConfig = { input: './src/index.js', - output: [ - getESM({ file: 'lib/index.es.js' }), - getCJS({ file: 'lib/index.cjs.js' }), - ], + output: [getESM({ file: 'lib/index.js' }), getCJS({ file: 'lib/index.cjs' })], external, plugins: getPlugins({ browser: false }), }; @@ -45,8 +42,8 @@ const serverConfig = { const browserConfig = { input: './src/index.js', output: [ - getESM({ file: 'lib/index.browser.es.js' }), - getCJS({ file: 'lib/index.browser.cjs.js' }), + getESM({ file: 'lib/index.browser.js' }), + getCJS({ file: 'lib/index.browser.cjs' }), ], external, plugins: getPlugins({ browser: true }), diff --git a/packages/font/setupTests.js b/packages/font/setupTests.js index 3bce79853..b599da88a 100644 --- a/packages/font/setupTests.js +++ b/packages/font/setupTests.js @@ -1,6 +1,11 @@ /* eslint-disable */ +import { jest } from '@jest/globals'; +import { createRequire } from 'module'; + import '../../polyfills'; +const require = createRequire(import.meta.url); + global.BROWSER = false; const customGlobal = global; diff --git a/packages/image/babel.config.js b/packages/image/babel.config.js index 27f83582f..02d1cbbdb 100644 --- a/packages/image/babel.config.js +++ b/packages/image/babel.config.js @@ -1 +1 @@ -module.exports = { extends: '../../babel.config.js' }; +export default { extends: '../../babel.config.js' }; diff --git a/packages/image/jest.config.js b/packages/image/jest.config.js index 62c218029..c224ed1dc 100644 --- a/packages/image/jest.config.js +++ b/packages/image/jest.config.js @@ -1,4 +1,4 @@ -module.exports = { +export default { automock: false, testRegex: 'tests/.*?(test)\\.js$', setupFiles: ['setupTests.js'], diff --git a/packages/image/package.json b/packages/image/package.json index d4ebf8da7..32c667d5d 100644 --- a/packages/image/package.json +++ b/packages/image/package.json @@ -5,11 +5,19 @@ "description": "Parses the images in png or jpeg format for react-pdf document", "author": "Diego Muracciole ", "homepage": "https://github.com/diegomura/react-pdf#readme", - "main": "./lib/index.cjs.js", - "module": "./lib/index.es.js", + "type": "module", + "main": "./lib/index.cjs", + "module": "./lib/index.js", "browser": { - "./lib/index.cjs.js": "./lib/index.browser.cjs.js", - "./lib/index.es.js": "./lib/index.browser.es.js" + "./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", @@ -17,7 +25,7 @@ "directory": "packages/image" }, "scripts": { - "test": "jest", + "test": "NODE_OPTIONS=\"--experimental-vm-modules\" jest", "build": "rimraf ./lib && rollup -c", "watch": "rimraf ./lib && rollup -c -w" }, diff --git a/packages/image/rollup.config.js b/packages/image/rollup.config.js index 571a97c9c..39aa78fe7 100644 --- a/packages/image/rollup.config.js +++ b/packages/image/rollup.config.js @@ -48,10 +48,7 @@ const getPlugins = ({ browser }) => [ const serverConfig = { input, - output: [ - getESM({ file: 'lib/index.es.js' }), - getCJS({ file: 'lib/index.cjs.js' }), - ], + output: [getESM({ file: 'lib/index.js' }), getCJS({ file: 'lib/index.cjs' })], external: getExternal({ browser: false }), plugins: getPlugins({ browser: false }), }; @@ -59,8 +56,8 @@ const serverConfig = { const browserConfig = { input, output: [ - getESM({ file: 'lib/index.browser.es.js' }), - getCJS({ file: 'lib/index.browser.cjs.js' }), + getESM({ file: 'lib/index.browser.js' }), + getCJS({ file: 'lib/index.browser.cjs' }), ], external: getExternal({ browser: true }), plugins: getPlugins({ browser: true }), diff --git a/packages/image/setupTests.js b/packages/image/setupTests.js index b3d953429..02e249cbc 100644 --- a/packages/image/setupTests.js +++ b/packages/image/setupTests.js @@ -1,4 +1,8 @@ /* eslint-disable import/no-extraneous-dependencies */ +import { jest } from '@jest/globals'; +import { createRequire } from 'module'; + +const require = createRequire(import.meta.url); const customGlobal = global; customGlobal.fetch = require('jest-fetch-mock'); diff --git a/packages/image/tests/resolve.test.js b/packages/image/tests/resolve.test.js index 917932833..f25e0e17b 100644 --- a/packages/image/tests/resolve.test.js +++ b/packages/image/tests/resolve.test.js @@ -1,8 +1,11 @@ import fs from 'fs'; import path from 'path'; +import url from 'url'; import resolveImage, { IMAGE_CACHE } from '../src/resolve'; +const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); + const jpgImageUrl = 'https://react-pdf.org/static/images/quijote1.jpg'; const pngImageUrl = 'https://react-pdf.org/static/images/quijote2.png'; const jpgLogalPath = path.join(__dirname, './assets/test.jpg'); diff --git a/packages/layout/babel.config.js b/packages/layout/babel.config.js index 831adcadc..defa6f8c2 100644 --- a/packages/layout/babel.config.js +++ b/packages/layout/babel.config.js @@ -1,3 +1,3 @@ -module.exports = { +export default { extends: '../../babel.config.js', }; diff --git a/packages/layout/jest.config.js b/packages/layout/jest.config.js index dbccc1991..24cd66a27 100644 --- a/packages/layout/jest.config.js +++ b/packages/layout/jest.config.js @@ -1,4 +1,4 @@ -module.exports = { +export default { automock: false, testRegex: 'tests/.*?(test)\\.js$', }; diff --git a/packages/layout/package.json b/packages/layout/package.json index e28842af6..66c53cf44 100644 --- a/packages/layout/package.json +++ b/packages/layout/package.json @@ -5,15 +5,23 @@ "description": "Resolve overall document component's layout", "author": "Diego Muracciole ", "homepage": "https://github.com/diegomura/react-pdf#readme", - "main": "lib/index.cjs.js", - "module": "lib/index.es.js", + "type": "module", + "main": "./lib/index.cjs", + "module": "./lib/index.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", "directory": "packages/layout" }, "scripts": { - "test": "jest", + "test": "NODE_OPTIONS=\"--experimental-vm-modules\" jest", "build": "rimraf ./lib && rollup -c", "watch": "rimraf ./lib && rollup -c -w" }, diff --git a/packages/layout/rollup.config.js b/packages/layout/rollup.config.js index 88f795e6c..0c250196d 100644 --- a/packages/layout/rollup.config.js +++ b/packages/layout/rollup.config.js @@ -29,10 +29,7 @@ const configBase = { }; const config = Object.assign({}, configBase, { - output: [ - getESM({ file: 'lib/index.es.js' }), - getCJS({ file: 'lib/index.cjs.js' }), - ], + output: [getESM({ file: 'lib/index.js' }), getCJS({ file: 'lib/index.cjs' })], }); export default config; diff --git a/packages/layout/setupTests.js b/packages/layout/setupTests.js index 3bce79853..efa0b37d3 100644 --- a/packages/layout/setupTests.js +++ b/packages/layout/setupTests.js @@ -1,6 +1,10 @@ /* eslint-disable */ +import { createRequire } from 'module'; + import '../../polyfills'; +const require = createRequire(import.meta.url); + global.BROWSER = false; const customGlobal = global; diff --git a/packages/layout/src/image/measureImage.js b/packages/layout/src/image/measureImage.js index 593a24f9b..f1e0e3267 100644 --- a/packages/layout/src/image/measureImage.js +++ b/packages/layout/src/image/measureImage.js @@ -1,4 +1,4 @@ -import Yoga from 'yoga-layout/sync'; +import Yoga from '../../yoga'; import getRatio from './getRatio'; import getMargin from '../node/getMargin'; diff --git a/packages/layout/src/node/getBorderWidth.js b/packages/layout/src/node/getBorderWidth.js index e2f82f131..0801389f4 100644 --- a/packages/layout/src/node/getBorderWidth.js +++ b/packages/layout/src/node/getBorderWidth.js @@ -1,4 +1,4 @@ -import Yoga from 'yoga-layout/sync'; +import Yoga from '../../yoga'; const getComputedBorder = (yogaNode, edge) => yogaNode ? yogaNode.getComputedBorder(edge) : 0; diff --git a/packages/layout/src/node/getMargin.js b/packages/layout/src/node/getMargin.js index 7bb0dd4f6..bb45ff8fc 100644 --- a/packages/layout/src/node/getMargin.js +++ b/packages/layout/src/node/getMargin.js @@ -1,4 +1,4 @@ -import Yoga from 'yoga-layout/sync'; +import Yoga from '../../yoga'; const getComputedMargin = (node, edge) => { const { yogaNode } = node; diff --git a/packages/layout/src/node/getPadding.js b/packages/layout/src/node/getPadding.js index c124b14e4..70e5afe52 100644 --- a/packages/layout/src/node/getPadding.js +++ b/packages/layout/src/node/getPadding.js @@ -1,4 +1,4 @@ -import Yoga from 'yoga-layout/sync'; +import Yoga from '../../yoga'; const getComputedPadding = (node, edge) => { const { yogaNode } = node; diff --git a/packages/layout/src/node/setAlign.js b/packages/layout/src/node/setAlign.js index c5c3c1d05..7e3edf527 100644 --- a/packages/layout/src/node/setAlign.js +++ b/packages/layout/src/node/setAlign.js @@ -1,5 +1,5 @@ -import Yoga from 'yoga-layout/sync'; import { upperFirst } from '@react-pdf/fns'; +import Yoga from '../../yoga'; const ALIGN = { 'flex-start': Yoga.ALIGN_FLEX_START, diff --git a/packages/layout/src/node/setBorderWidth.js b/packages/layout/src/node/setBorderWidth.js index 09c07ab81..58b3bcf66 100644 --- a/packages/layout/src/node/setBorderWidth.js +++ b/packages/layout/src/node/setBorderWidth.js @@ -1,4 +1,4 @@ -import Yoga from 'yoga-layout/sync'; +import Yoga from '../../yoga'; import setYogaValue from './setYogaValue'; diff --git a/packages/layout/src/node/setDisplay.js b/packages/layout/src/node/setDisplay.js index 5bcc13eea..bf06ab00f 100644 --- a/packages/layout/src/node/setDisplay.js +++ b/packages/layout/src/node/setDisplay.js @@ -1,4 +1,4 @@ -import Yoga from 'yoga-layout/sync'; +import Yoga from '../../yoga'; /** * Set display attribute to node's Yoga instance diff --git a/packages/layout/src/node/setFlexDirection.js b/packages/layout/src/node/setFlexDirection.js index eb0f476ee..85cc2a77a 100644 --- a/packages/layout/src/node/setFlexDirection.js +++ b/packages/layout/src/node/setFlexDirection.js @@ -1,4 +1,4 @@ -import Yoga from 'yoga-layout/sync'; +import Yoga from '../../yoga'; const FLEX_DIRECTIONS = { row: Yoga.FLEX_DIRECTION_ROW, diff --git a/packages/layout/src/node/setFlexWrap.js b/packages/layout/src/node/setFlexWrap.js index 51ba30f48..f7ad6e1b0 100644 --- a/packages/layout/src/node/setFlexWrap.js +++ b/packages/layout/src/node/setFlexWrap.js @@ -1,4 +1,4 @@ -import Yoga from 'yoga-layout/sync'; +import Yoga from '../../yoga'; const FLEX_WRAP = { wrap: Yoga.WRAP_WRAP, diff --git a/packages/layout/src/node/setGap.js b/packages/layout/src/node/setGap.js index d7a8d56fe..f327dd464 100644 --- a/packages/layout/src/node/setGap.js +++ b/packages/layout/src/node/setGap.js @@ -1,5 +1,5 @@ -import Yoga from 'yoga-layout/sync'; import { isNil, matchPercent } from '@react-pdf/fns'; +import Yoga from '../../yoga'; const checkPercents = (attr, value) => { const percent = matchPercent(value); diff --git a/packages/layout/src/node/setJustifyContent.js b/packages/layout/src/node/setJustifyContent.js index 0b3cd4265..509f80fd9 100644 --- a/packages/layout/src/node/setJustifyContent.js +++ b/packages/layout/src/node/setJustifyContent.js @@ -1,5 +1,5 @@ -import Yoga from 'yoga-layout/sync'; import { isNil } from '@react-pdf/fns'; +import Yoga from '../../yoga'; const JUSTIFY_CONTENT = { center: Yoga.JUSTIFY_CENTER, diff --git a/packages/layout/src/node/setMargin.js b/packages/layout/src/node/setMargin.js index 9bad014a7..4c81a42ea 100644 --- a/packages/layout/src/node/setMargin.js +++ b/packages/layout/src/node/setMargin.js @@ -1,4 +1,4 @@ -import Yoga from 'yoga-layout/sync'; +import Yoga from '../../yoga'; import setYogaValue from './setYogaValue'; diff --git a/packages/layout/src/node/setOverflow.js b/packages/layout/src/node/setOverflow.js index 3793234b5..ab86a1b93 100644 --- a/packages/layout/src/node/setOverflow.js +++ b/packages/layout/src/node/setOverflow.js @@ -1,5 +1,5 @@ -import Yoga from 'yoga-layout/sync'; import { isNil } from '@react-pdf/fns'; +import Yoga from '../../yoga'; const OVERFLOW = { hidden: Yoga.OVERFLOW_HIDDEN, diff --git a/packages/layout/src/node/setPadding.js b/packages/layout/src/node/setPadding.js index 4a948950d..b403803b7 100644 --- a/packages/layout/src/node/setPadding.js +++ b/packages/layout/src/node/setPadding.js @@ -1,4 +1,4 @@ -import Yoga from 'yoga-layout/sync'; +import Yoga from '../../yoga'; import setYogaValue from './setYogaValue'; diff --git a/packages/layout/src/node/setPosition.js b/packages/layout/src/node/setPosition.js index 82a9a8f6c..790330300 100644 --- a/packages/layout/src/node/setPosition.js +++ b/packages/layout/src/node/setPosition.js @@ -1,4 +1,4 @@ -import Yoga from 'yoga-layout/sync'; +import Yoga from '../../yoga'; import setYogaValue from './setYogaValue'; diff --git a/packages/layout/src/node/setPositionType.js b/packages/layout/src/node/setPositionType.js index 79573e9ae..69761ea98 100644 --- a/packages/layout/src/node/setPositionType.js +++ b/packages/layout/src/node/setPositionType.js @@ -1,5 +1,5 @@ -import Yoga from 'yoga-layout/sync'; import { isNil } from '@react-pdf/fns'; +import Yoga from '../../yoga'; /** * Set position type attribute to node's Yoga instance diff --git a/packages/layout/src/steps/resolveDimensions.js b/packages/layout/src/steps/resolveDimensions.js index e4f21ba73..dc3e9d099 100644 --- a/packages/layout/src/steps/resolveDimensions.js +++ b/packages/layout/src/steps/resolveDimensions.js @@ -1,6 +1,6 @@ -import Yoga from 'yoga-layout/sync'; import * as P from '@react-pdf/primitives'; import { isNil, compose } from '@react-pdf/fns'; +import Yoga from '../../yoga'; import getMargin from '../node/getMargin'; import getPadding from '../node/getPadding'; diff --git a/packages/layout/src/svg/measureSvg.js b/packages/layout/src/svg/measureSvg.js index 52e4a3ac8..74b5525bd 100644 --- a/packages/layout/src/svg/measureSvg.js +++ b/packages/layout/src/svg/measureSvg.js @@ -1,4 +1,4 @@ -import Yoga from 'yoga-layout/sync'; +import Yoga from '../../yoga'; const getAspectRatio = viewbox => { if (!viewbox) return null; diff --git a/packages/layout/src/text/measureText.js b/packages/layout/src/text/measureText.js index ea3afe2d0..8b9e5f658 100644 --- a/packages/layout/src/text/measureText.js +++ b/packages/layout/src/text/measureText.js @@ -1,6 +1,6 @@ /* eslint-disable no-param-reassign */ -import Yoga from 'yoga-layout/sync'; +import Yoga from '../../yoga'; import layoutText from './layoutText'; import linesWidth from './linesWidth'; diff --git a/packages/layout/tests/node/getBorderWidth.test.js b/packages/layout/tests/node/getBorderWidth.test.js index 5110f6ab7..fefb26d2c 100644 --- a/packages/layout/tests/node/getBorderWidth.test.js +++ b/packages/layout/tests/node/getBorderWidth.test.js @@ -1,4 +1,4 @@ -import Yoga from 'yoga-layout/sync'; +import Yoga from '../../yoga'; import getBorderWidth from '../../src/node/getBorderWidth'; diff --git a/packages/layout/tests/node/getMargin.test.js b/packages/layout/tests/node/getMargin.test.js index b398e75c9..b098790cd 100644 --- a/packages/layout/tests/node/getMargin.test.js +++ b/packages/layout/tests/node/getMargin.test.js @@ -1,4 +1,4 @@ -import Yoga from 'yoga-layout/sync'; +import Yoga from '../../yoga'; import getMargin from '../../src/node/getMargin'; diff --git a/packages/layout/tests/node/getPadding.test.js b/packages/layout/tests/node/getPadding.test.js index 526314158..d9719a20b 100644 --- a/packages/layout/tests/node/getPadding.test.js +++ b/packages/layout/tests/node/getPadding.test.js @@ -1,4 +1,4 @@ -import Yoga from 'yoga-layout/sync'; +import Yoga from '../../yoga'; import getPadding from '../../src/node/getPadding'; diff --git a/packages/layout/tests/node/setAlignContent.test.js b/packages/layout/tests/node/setAlignContent.test.js index dad2eb489..80f757243 100644 --- a/packages/layout/tests/node/setAlignContent.test.js +++ b/packages/layout/tests/node/setAlignContent.test.js @@ -1,4 +1,5 @@ -import Yoga from 'yoga-layout/sync'; +import { jest } from '@jest/globals'; +import Yoga from '../../yoga'; import setAlignContent from '../../src/node/setAlignContent'; diff --git a/packages/layout/tests/node/setAlignItems.test.js b/packages/layout/tests/node/setAlignItems.test.js index ea1800535..5ab866e44 100644 --- a/packages/layout/tests/node/setAlignItems.test.js +++ b/packages/layout/tests/node/setAlignItems.test.js @@ -1,4 +1,5 @@ -import Yoga from 'yoga-layout/sync'; +import { jest } from '@jest/globals'; +import Yoga from '../../yoga'; import setAlignItems from '../../src/node/setAlignItems'; diff --git a/packages/layout/tests/node/setAlignSelf.test.js b/packages/layout/tests/node/setAlignSelf.test.js index e84194693..f70083881 100644 --- a/packages/layout/tests/node/setAlignSelf.test.js +++ b/packages/layout/tests/node/setAlignSelf.test.js @@ -1,4 +1,5 @@ -import Yoga from 'yoga-layout/sync'; +import { jest } from '@jest/globals'; +import Yoga from '../../yoga'; import setAlignSelf from '../../src/node/setAlignSelf'; diff --git a/packages/layout/tests/node/setAspectRatio.test.js b/packages/layout/tests/node/setAspectRatio.test.js index c1b0a3352..4c4b1602d 100644 --- a/packages/layout/tests/node/setAspectRatio.test.js +++ b/packages/layout/tests/node/setAspectRatio.test.js @@ -1,3 +1,4 @@ +import { jest } from '@jest/globals'; import setAspectRatio from '../../src/node/setAspectRatio'; describe('node setAspectRatio', () => { diff --git a/packages/layout/tests/node/setBorderWidth.test.js b/packages/layout/tests/node/setBorderWidth.test.js index 0d09c2750..1e2d9de23 100644 --- a/packages/layout/tests/node/setBorderWidth.test.js +++ b/packages/layout/tests/node/setBorderWidth.test.js @@ -1,4 +1,5 @@ -import Yoga from 'yoga-layout/sync'; +import { jest } from '@jest/globals'; +import Yoga from '../../yoga'; import setBorder, { setBorderTop, diff --git a/packages/layout/tests/node/setDimension.test.js b/packages/layout/tests/node/setDimension.test.js index 28463aff9..8c3a1a56b 100644 --- a/packages/layout/tests/node/setDimension.test.js +++ b/packages/layout/tests/node/setDimension.test.js @@ -1,3 +1,4 @@ +import { jest } from '@jest/globals'; import { setWidth, setMinWidth, diff --git a/packages/layout/tests/node/setDisplay.test.js b/packages/layout/tests/node/setDisplay.test.js index 15e64ec5e..bd733613d 100644 --- a/packages/layout/tests/node/setDisplay.test.js +++ b/packages/layout/tests/node/setDisplay.test.js @@ -1,4 +1,5 @@ -import Yoga from 'yoga-layout/sync'; +import { jest } from '@jest/globals'; +import Yoga from '../../yoga'; import setDisplay from '../../src/node/setDisplay'; diff --git a/packages/layout/tests/node/setFlexBasis.test.js b/packages/layout/tests/node/setFlexBasis.test.js index 39803d896..a5d54fc30 100644 --- a/packages/layout/tests/node/setFlexBasis.test.js +++ b/packages/layout/tests/node/setFlexBasis.test.js @@ -1,3 +1,4 @@ +import { jest } from '@jest/globals'; import setFlexBasis from '../../src/node/setFlexBasis'; describe('node setFlexBasis', () => { diff --git a/packages/layout/tests/node/setFlexDirection.test.js b/packages/layout/tests/node/setFlexDirection.test.js index 1d8d895c3..38ce13274 100644 --- a/packages/layout/tests/node/setFlexDirection.test.js +++ b/packages/layout/tests/node/setFlexDirection.test.js @@ -1,4 +1,5 @@ -import Yoga from 'yoga-layout/sync'; +import { jest } from '@jest/globals'; +import Yoga from '../../yoga'; import setFlexDirection from '../../src/node/setFlexDirection'; diff --git a/packages/layout/tests/node/setFlexGrow.test.js b/packages/layout/tests/node/setFlexGrow.test.js index 6da4b82bc..acd386e51 100644 --- a/packages/layout/tests/node/setFlexGrow.test.js +++ b/packages/layout/tests/node/setFlexGrow.test.js @@ -1,3 +1,4 @@ +import { jest } from '@jest/globals'; import setFlexGrow from '../../src/node/setFlexGrow'; describe('node setFlexGrow', () => { diff --git a/packages/layout/tests/node/setFlexShrink.test.js b/packages/layout/tests/node/setFlexShrink.test.js index 456c3df04..4a3a94461 100644 --- a/packages/layout/tests/node/setFlexShrink.test.js +++ b/packages/layout/tests/node/setFlexShrink.test.js @@ -1,3 +1,4 @@ +import { jest } from '@jest/globals'; import setFlexShrink from '../../src/node/setFlexShrink'; describe('node setFlexShrink', () => { diff --git a/packages/layout/tests/node/setFlexWrap.test.js b/packages/layout/tests/node/setFlexWrap.test.js index f66e7f380..b79782f20 100644 --- a/packages/layout/tests/node/setFlexWrap.test.js +++ b/packages/layout/tests/node/setFlexWrap.test.js @@ -1,4 +1,5 @@ -import Yoga from 'yoga-layout/sync'; +import { jest } from '@jest/globals'; +import Yoga from '../../yoga'; import setFlexWrap from '../../src/node/setFlexWrap'; diff --git a/packages/layout/tests/node/setJustifyContent.test.js b/packages/layout/tests/node/setJustifyContent.test.js index 6ddd88aaf..1d8cc3643 100644 --- a/packages/layout/tests/node/setJustifyContent.test.js +++ b/packages/layout/tests/node/setJustifyContent.test.js @@ -1,4 +1,5 @@ -import Yoga from 'yoga-layout/sync'; +import { jest } from '@jest/globals'; +import Yoga from '../../yoga'; import setJustifyContent from '../../src/node/setJustifyContent'; diff --git a/packages/layout/tests/node/setMargin.test.js b/packages/layout/tests/node/setMargin.test.js index f6aeeb0e0..fca16849e 100644 --- a/packages/layout/tests/node/setMargin.test.js +++ b/packages/layout/tests/node/setMargin.test.js @@ -1,4 +1,5 @@ -import Yoga from 'yoga-layout/sync'; +import { jest } from '@jest/globals'; +import Yoga from '../../yoga'; import setMargin, { setMarginTop, diff --git a/packages/layout/tests/node/setOverflow.test.js b/packages/layout/tests/node/setOverflow.test.js index 33f60b1c3..871c6b5ea 100644 --- a/packages/layout/tests/node/setOverflow.test.js +++ b/packages/layout/tests/node/setOverflow.test.js @@ -1,4 +1,5 @@ -import Yoga from 'yoga-layout/sync'; +import { jest } from '@jest/globals'; +import Yoga from '../../yoga'; import setOverflow from '../../src/node/setOverflow'; diff --git a/packages/layout/tests/node/setPadding.test.js b/packages/layout/tests/node/setPadding.test.js index cce9fc8f2..91e3b896e 100644 --- a/packages/layout/tests/node/setPadding.test.js +++ b/packages/layout/tests/node/setPadding.test.js @@ -1,4 +1,5 @@ -import Yoga from 'yoga-layout/sync'; +import { jest } from '@jest/globals'; +import Yoga from '../../yoga'; import setPadding, { setPaddingTop, diff --git a/packages/layout/tests/node/setPosition.test.js b/packages/layout/tests/node/setPosition.test.js index 3e1dc029b..3665b0338 100644 --- a/packages/layout/tests/node/setPosition.test.js +++ b/packages/layout/tests/node/setPosition.test.js @@ -1,4 +1,5 @@ -import Yoga from 'yoga-layout/sync'; +import { jest } from '@jest/globals'; +import Yoga from '../../yoga'; import setPosition, { setPositionTop, diff --git a/packages/layout/tests/node/setPositionType.test.js b/packages/layout/tests/node/setPositionType.test.js index fb7e9fb3d..caab729f1 100644 --- a/packages/layout/tests/node/setPositionType.test.js +++ b/packages/layout/tests/node/setPositionType.test.js @@ -1,4 +1,5 @@ -import Yoga from 'yoga-layout/sync'; +import { jest } from '@jest/globals'; +import Yoga from '../../yoga'; import setPositionType from '../../src/node/setPositionType'; diff --git a/packages/layout/tests/text/layoutText.test.js b/packages/layout/tests/text/layoutText.test.js index 1fdeecc64..dfcfb6ee5 100644 --- a/packages/layout/tests/text/layoutText.test.js +++ b/packages/layout/tests/text/layoutText.test.js @@ -1,3 +1,4 @@ +import { jest } from '@jest/globals'; import * as P from '@react-pdf/primitives'; import layoutText from '../../src/text/layoutText'; diff --git a/packages/layout/yoga.js b/packages/layout/yoga.js new file mode 100644 index 000000000..04ec637a4 --- /dev/null +++ b/packages/layout/yoga.js @@ -0,0 +1,7 @@ +import yogaModule from 'yoga-layout/sync'; + +// yoga-layout sets default export using non-standard __esModule property, so we need to +// make an additional check in case it's used in a bundler that does not support it. +const Yoga = 'default' in yogaModule ? yogaModule.default : yogaModule; + +export default Yoga; diff --git a/packages/pdfkit/.eslintrc.js b/packages/pdfkit/.eslintrc.js deleted file mode 100644 index 7157fdfed..000000000 --- a/packages/pdfkit/.eslintrc.js +++ /dev/null @@ -1,43 +0,0 @@ -module.exports = { - extends: ['../../.eslintrc.js'], - rules: { - yoda: 0, - radix: 0, - 'no-var': 1, - 'one-var': 1, - camelcase: 0, - 'no-shadow': 0, - 'no-bitwise': 0, - 'no-plusplus': 0, - 'vars-on-top': 0, - 'no-continue': 0, - 'prefer-const': 0, - 'default-case': 0, - 'dot-notation': 1, - 'guard-for-in': 0, - 'no-undef-init': 1, - 'no-unused-vars': 1, - 'no-else-return': 1, - 'no-path-concat': 0, - 'import/no-cycle': 0, - 'no-multi-assign': 0, - 'no-new-wrappers': 0, - 'prefer-template': 0, - 'no-throw-literal': 0, - 'no-return-assign': 0, - 'no-useless-escape': 1, - 'no-nested-ternary': 0, - 'consistent-return': 0, - 'no-param-reassign': 0, - 'prefer-rest-params': 0, - 'prefer-object-spread': 0, - 'prefer-destructuring': 0, - 'max-classes-per-file': 0, - 'no-restricted-syntax': 0, - 'no-use-before-define': 1, - 'no-buffer-constructor': 1, - 'class-methods-use-this': 0, - 'import/no-mutable-exports': 0, - 'lines-between-class-members': 0 - } -}; diff --git a/packages/pdfkit/.eslintrc.json b/packages/pdfkit/.eslintrc.json new file mode 100644 index 000000000..23ae02be5 --- /dev/null +++ b/packages/pdfkit/.eslintrc.json @@ -0,0 +1,43 @@ +{ + "extends": ["../../.eslintrc.json"], + "rules": { + "yoda": 0, + "radix": 0, + "no-var": 1, + "one-var": 1, + "camelcase": 0, + "no-shadow": 0, + "no-bitwise": 0, + "no-plusplus": 0, + "vars-on-top": 0, + "no-continue": 0, + "prefer-const": 0, + "default-case": 0, + "dot-notation": 1, + "guard-for-in": 0, + "no-undef-init": 1, + "no-unused-vars": 1, + "no-else-return": 1, + "no-path-concat": 0, + "import/no-cycle": 0, + "no-multi-assign": 0, + "no-new-wrappers": 0, + "prefer-template": 0, + "no-throw-literal": 0, + "no-return-assign": 0, + "no-useless-escape": 1, + "no-nested-ternary": 0, + "consistent-return": 0, + "no-param-reassign": 0, + "prefer-rest-params": 0, + "prefer-object-spread": 0, + "prefer-destructuring": 0, + "max-classes-per-file": 0, + "no-restricted-syntax": 0, + "no-use-before-define": 1, + "no-buffer-constructor": 1, + "class-methods-use-this": 0, + "import/no-mutable-exports": 0, + "lines-between-class-members": 0 + } +} diff --git a/packages/pdfkit/babel.config.js b/packages/pdfkit/babel.config.js index 27f83582f..02d1cbbdb 100644 --- a/packages/pdfkit/babel.config.js +++ b/packages/pdfkit/babel.config.js @@ -1 +1 @@ -module.exports = { extends: '../../babel.config.js' }; +export default { extends: '../../babel.config.js' }; diff --git a/packages/pdfkit/package.json b/packages/pdfkit/package.json index e00bbbab3..c22f32a1d 100644 --- a/packages/pdfkit/package.json +++ b/packages/pdfkit/package.json @@ -3,17 +3,25 @@ "version": "3.0.4", "license": "MIT", "description": "A PDF generation library for Node.js", - "main": "./lib/pdfkit.cjs.js", - "module": "./lib/pdfkit.es.js", + "type": "module", + "main": "./lib/pdfkit.cjs", + "module": "./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" + } + }, "repository": { "type": "git", "url": "https://github.com/diegomura/react-pdf.git", "directory": "packages/pdfkit" }, - "browser": { - "./lib/pdfkit.es.js": "./lib/pdfkit.browser.es.js", - "./lib/pdfkit.cjs.js": "./lib/pdfkit.browser.cjs.js" - }, "author": { "name": "Devon Govett", "email": "devongovett@gmail.com", @@ -21,7 +29,7 @@ }, "scripts": { "clear": "rimraf ./lib ./src/font/data/*.json", - "parse:afm": "babel-node ./src/font/data/compressData.js", + "parse:afm": "node ./src/font/data/compressData.js", "build": "npm run clear && npm run parse:afm && rollup -c ", "watch": "npm run clear && npm run parse:afm && rollup -c -w" }, diff --git a/packages/pdfkit/rollup.config.js b/packages/pdfkit/rollup.config.js index d95868bf7..bccb05e3b 100644 --- a/packages/pdfkit/rollup.config.js +++ b/packages/pdfkit/rollup.config.js @@ -48,6 +48,15 @@ const getPlugins = ({ browser, minify = false }) => [ ignore(['fs']), alias({ entries: [ + // See https://github.com/browserify/browserify-zlib/pull/45 + { + find: 'pako/lib/zlib/zstream', + replacement: 'pako/lib/zlib/zstream.js' + }, + { + find: 'pako/lib/zlib/constants', + replacement: 'pako/lib/zlib/constants.js' + }, { find: 'stream', replacement: 'vite-compatible-readable-stream' }, { find: 'zlib', replacement: 'browserify-zlib' } ] @@ -72,8 +81,8 @@ const getPlugins = ({ browser, minify = false }) => [ const serverConfig = { input, output: [ - getESM({ file: 'lib/pdfkit.es.js' }), - getCJS({ file: 'lib/pdfkit.cjs.js' }) + getESM({ file: 'lib/pdfkit.js' }), + getCJS({ file: 'lib/pdfkit.cjs' }) ], external: getExternal({ browser: false }), plugins: getPlugins({ browser: false }) @@ -82,8 +91,8 @@ const serverConfig = { const serverProdConfig = { input, output: [ - getESM({ file: 'lib/pdfkit.es.min.js' }), - getCJS({ file: 'lib/pdfkit.cjs.min.js' }) + getESM({ file: 'lib/pdfkit.min.js' }), + getCJS({ file: 'lib/pdfkit.min.cjs' }) ], external: getExternal({ browser: false }), plugins: getPlugins({ browser: false, minify: true }) @@ -92,8 +101,8 @@ const serverProdConfig = { const browserConfig = { input, output: [ - getESM({ file: 'lib/pdfkit.browser.es.js' }), - getCJS({ file: 'lib/pdfkit.browser.cjs.js' }) + getESM({ file: 'lib/pdfkit.browser.js' }), + getCJS({ file: 'lib/pdfkit.browser.cjs' }) ], external: getExternal({ browser: true }), plugins: getPlugins({ browser: true }) @@ -102,8 +111,8 @@ const browserConfig = { const browserProdConfig = Object.assign({}, browserConfig, { input, output: [ - getESM({ file: 'lib/pdfkit.browser.es.min.js' }), - getCJS({ file: 'lib/pdfkit.browser.cjs.min.js' }) + getESM({ file: 'lib/pdfkit.browser.min.js' }), + getCJS({ file: 'lib/pdfkit.browser.min.cjs' }) ], external: getExternal({ browser: true }), plugins: getPlugins({ browser: true, minify: true }) diff --git a/packages/pdfkit/src/font/afm.js b/packages/pdfkit/src/font/afm.js index 7fcbe86ea..95e55192b 100644 --- a/packages/pdfkit/src/font/afm.js +++ b/packages/pdfkit/src/font/afm.js @@ -2,7 +2,9 @@ /* eslint-disable no-cond-assign */ import fs from 'fs'; -import range from '../utils/range'; +// This file is ran directly with Node - needs to have .js extension +// eslint-disable-next-line import/extensions +import range from '../utils/range.js'; const WIN_ANSI_MAP = { 402: 131, diff --git a/packages/pdfkit/src/font/data/compressData.js b/packages/pdfkit/src/font/data/compressData.js index c9f5f2b8f..0a57975de 100644 --- a/packages/pdfkit/src/font/data/compressData.js +++ b/packages/pdfkit/src/font/data/compressData.js @@ -1,6 +1,11 @@ import fs from 'fs'; +import url from 'url'; import { basename, extname } from 'path'; -import { parse } from '../afm'; +// This file is ran directly with Node - needs to have .js extension +// eslint-disable-next-line import/extensions +import { parse } from '../afm.js'; + +const __dirname = url.fileURLToPath(new URL('.', import.meta.url)); const generateJsonFiles = () => { const files = fs.readdirSync(__dirname); diff --git a/packages/pdfkit/src/mixins/attachments.js b/packages/pdfkit/src/mixins/attachments.js index 133c00d17..cf7c8ef59 100644 --- a/packages/pdfkit/src/mixins/attachments.js +++ b/packages/pdfkit/src/mixins/attachments.js @@ -1,6 +1,10 @@ import fs from 'fs'; -import * as CryptoJS from 'crypto-js/core'; -import MD5 from 'crypto-js/md5'; +// This file is ran directly with Node - needs to have .js extension +// eslint-disable-next-line import/extensions +import * as CryptoJS from 'crypto-js/core.js'; +// This file is ran directly with Node - needs to have .js extension +// eslint-disable-next-line import/extensions +import MD5 from 'crypto-js/md5.js'; export default { /** diff --git a/packages/pdfkit/src/security.js b/packages/pdfkit/src/security.js index d73ca31bd..8b78fa53c 100644 --- a/packages/pdfkit/src/security.js +++ b/packages/pdfkit/src/security.js @@ -5,7 +5,9 @@ By Yang Liu */ -import MD5 from 'crypto-js/md5'; +// This file is ran directly with Node - needs to have .js extension +// eslint-disable-next-line import/extensions +import MD5 from 'crypto-js/md5.js'; const wordArrayToBuffer = wordArray => { const byteArray = []; diff --git a/packages/png-js/.eslintrc.js b/packages/png-js/.eslintrc.js deleted file mode 100644 index 62e8226a9..000000000 --- a/packages/png-js/.eslintrc.js +++ /dev/null @@ -1,22 +0,0 @@ -module.exports = { - extends: ['../../.eslintrc.js'], - rules: { - yoda: 0, - 'no-var': 0, - 'func-names': 0, - 'no-bitwise': 0, - 'no-plusplus': 0, - 'vars-on-top': 0, - 'no-loop-func': 0, - 'default-case': 0, - 'prefer-spread': 0, - 'no-cond-assign': 0, - 'no-multi-assign': 0, - 'no-param-reassign': 0, - 'no-nested-ternary': 0, - 'consistent-return': 0, - 'prefer-destructuring': 0, - 'no-buffer-constructor': 1, - 'no-constant-condition': 0, - }, -}; diff --git a/packages/png-js/.eslintrc.json b/packages/png-js/.eslintrc.json new file mode 100644 index 000000000..aab3c80bd --- /dev/null +++ b/packages/png-js/.eslintrc.json @@ -0,0 +1,22 @@ +{ + "extends": ["../../.eslintrc.json"], + "rules": { + "yoda": 0, + "no-var": 0, + "func-names": 0, + "no-bitwise": 0, + "no-plusplus": 0, + "vars-on-top": 0, + "no-loop-func": 0, + "default-case": 0, + "prefer-spread": 0, + "no-cond-assign": 0, + "no-multi-assign": 0, + "no-param-reassign": 0, + "no-nested-ternary": 0, + "consistent-return": 0, + "prefer-destructuring": 0, + "no-buffer-constructor": 1, + "no-constant-condition": 0 + } +} diff --git a/packages/png-js/babel.config.js b/packages/png-js/babel.config.js index 27f83582f..02d1cbbdb 100644 --- a/packages/png-js/babel.config.js +++ b/packages/png-js/babel.config.js @@ -1 +1 @@ -module.exports = { extends: '../../babel.config.js' }; +export default { extends: '../../babel.config.js' }; diff --git a/packages/png-js/package.json b/packages/png-js/package.json index 79939b2e0..045c4c850 100644 --- a/packages/png-js/package.json +++ b/packages/png-js/package.json @@ -3,11 +3,19 @@ "description": "A PNG decoder in JS", "version": "2.2.0", "license": "MIT", - "main": "./lib/png-js.cjs.js", - "module": "./lib/png-js.es.js", + "type": "module", + "main": "./lib/png-js.cjs", + "module": "./lib/png-js.js", "browser": { - "./lib/png-js.es.js": "./lib/png-js.browser.es.js", - "./lib/png-js.cjs.js": "./lib/png-js.browser.cjs.js" + "./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" + } }, "repository": { "type": "git", diff --git a/packages/png-js/rollup.config.js b/packages/png-js/rollup.config.js index 8249a14d8..0474b3371 100644 --- a/packages/png-js/rollup.config.js +++ b/packages/png-js/rollup.config.js @@ -60,8 +60,8 @@ const getPlugins = ({ browser }) => [ const serverConfig = { input, output: [ - getESM({ file: 'lib/png-js.es.js' }), - getCJS({ file: 'lib/png-js.cjs.js' }), + getESM({ file: 'lib/png-js.js' }), + getCJS({ file: 'lib/png-js.cjs' }), ], external: getExternal({ browser: false }), plugins: getPlugins({ browser: false }), @@ -70,8 +70,8 @@ const serverConfig = { const browserConfig = { input, output: [ - getESM({ file: 'lib/png-js.browser.es.js' }), - getCJS({ file: 'lib/png-js.browser.cjs.js' }), + getESM({ file: 'lib/png-js.browser.js' }), + getCJS({ file: 'lib/png-js.browser.cjs' }), ], external: getExternal({ browser: true }), plugins: getPlugins({ browser: true }), diff --git a/packages/primitives/babel.config.js b/packages/primitives/babel.config.js index 27f83582f..02d1cbbdb 100644 --- a/packages/primitives/babel.config.js +++ b/packages/primitives/babel.config.js @@ -1 +1 @@ -module.exports = { extends: '../../babel.config.js' }; +export default { extends: '../../babel.config.js' }; diff --git a/packages/primitives/jest.config.js b/packages/primitives/jest.config.js index 1a99b7295..40b1faa8e 100644 --- a/packages/primitives/jest.config.js +++ b/packages/primitives/jest.config.js @@ -1,3 +1,3 @@ -module.exports = { +export default { testRegex: 'tests/.*?(test)\\.js$', }; diff --git a/packages/primitives/package.json b/packages/primitives/package.json index 5edf4f0da..59198fa94 100644 --- a/packages/primitives/package.json +++ b/packages/primitives/package.json @@ -5,8 +5,16 @@ "description": "Define uninitialized elements", "author": "Diego Muracciole ", "homepage": "https://github.com/diegomura/react-pdf#readme", + "type": "module", "main": "./lib/index.js", "module": "./src/index.js", + "exports": { + ".": { + "import": "./src/index.js", + "require": "./lib/index.js", + "default": "./src/index.js" + } + }, "repository": { "type": "git", "url": "https://github.com/diegomura/react-pdf.git", @@ -14,7 +22,7 @@ }, "scripts": { "build": "babel src --out-dir lib", - "test": "jest" + "test": "NODE_OPTIONS=\"--experimental-vm-modules\" jest" }, "files": [ "lib", diff --git a/packages/primitives/tests/index.test.js b/packages/primitives/tests/index.test.js index 3d88b90a2..74adf56c8 100644 --- a/packages/primitives/tests/index.test.js +++ b/packages/primitives/tests/index.test.js @@ -1,4 +1,4 @@ -const primitives = require('../src'); +import * as primitives from '../src'; describe('primitives', () => { test('should export group', () => { diff --git a/packages/render/babel.config.js b/packages/render/babel.config.js index 27f83582f..02d1cbbdb 100644 --- a/packages/render/babel.config.js +++ b/packages/render/babel.config.js @@ -1 +1 @@ -module.exports = { extends: '../../babel.config.js' }; +export default { extends: '../../babel.config.js' }; diff --git a/packages/render/jest.config.js b/packages/render/jest.config.js index 1a99b7295..40b1faa8e 100644 --- a/packages/render/jest.config.js +++ b/packages/render/jest.config.js @@ -1,3 +1,3 @@ -module.exports = { +export default { testRegex: 'tests/.*?(test)\\.js$', }; diff --git a/packages/render/package.json b/packages/render/package.json index 0035e029c..ec25bf197 100644 --- a/packages/render/package.json +++ b/packages/render/package.json @@ -5,15 +5,23 @@ "description": "A render engine for Node and the browser", "author": "Diego Muracciole ", "homepage": "https://github.com/diegomura/react-pdf#readme", - "main": "lib/index.cjs.js", - "module": "lib/index.es.js", + "type": "module", + "main": "./lib/index.cjs", + "module": "./lib/index.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", "directory": "packages/render" }, "scripts": { - "test": "jest", + "test": "NODE_OPTIONS=\"--experimental-vm-modules\" jest", "build": "rimraf ./lib && rollup -c", "watch": "rimraf ./lib && rollup -c -w" }, diff --git a/packages/render/rollup.config.js b/packages/render/rollup.config.js index 7f5613d46..2a3bc64a6 100644 --- a/packages/render/rollup.config.js +++ b/packages/render/rollup.config.js @@ -32,10 +32,7 @@ const configBase = { }; const config = Object.assign({}, configBase, { - output: [ - getESM({ file: 'lib/index.es.js' }), - getCJS({ file: 'lib/index.cjs.js' }), - ], + output: [getESM({ file: 'lib/index.js' }), getCJS({ file: 'lib/index.cjs' })], }); export default config; diff --git a/packages/render/tests/ctx.js b/packages/render/tests/ctx.js index 461373587..adffaefff 100644 --- a/packages/render/tests/ctx.js +++ b/packages/render/tests/ctx.js @@ -1,3 +1,5 @@ +import { jest } from '@jest/globals'; + const createCTX = () => { const instance = {}; diff --git a/packages/renderer/.size-limit.js b/packages/renderer/.size-limit.cjs similarity index 90% rename from packages/renderer/.size-limit.js rename to packages/renderer/.size-limit.cjs index 0900727bf..08a75c703 100644 --- a/packages/renderer/.size-limit.js +++ b/packages/renderer/.size-limit.cjs @@ -2,7 +2,7 @@ const webpack = require('webpack'); module.exports = [ { - path: 'lib/react-pdf.browser.es.js', + path: 'lib/react-pdf.browser.js', limit: '550 kB', modifyWebpackConfig: config => { diff --git a/packages/renderer/babel.config.js b/packages/renderer/babel.config.js index 27f83582f..02d1cbbdb 100644 --- a/packages/renderer/babel.config.js +++ b/packages/renderer/babel.config.js @@ -1 +1 @@ -module.exports = { extends: '../../babel.config.js' }; +export default { extends: '../../babel.config.js' }; diff --git a/packages/renderer/index.d.ts b/packages/renderer/index.d.ts index d540942e8..46a421b00 100644 --- a/packages/renderer/index.d.ts +++ b/packages/renderer/index.d.ts @@ -13,6 +13,12 @@ import { PageMode, } from '@react-pdf/types'; +declare class ReactPDF { + static default: typeof ReactPDF; +} + +export = ReactPDF; + declare namespace ReactPDF { interface Styles { [key: string]: Style; @@ -459,14 +465,18 @@ declare namespace ReactPDF { */ class PDFViewer extends React.Component {} - interface PDFDownloadLinkProps extends Omit, "href"> { + interface PDFDownloadLinkProps + extends Omit, 'href'> { /** PDF filename. Alias for anchor tag `download` attribute. */ fileName?: string; document: React.ReactElement; children?: | React.ReactNode | ((params: BlobProviderParams) => React.ReactNode); - onClick?(event: React.MouseEvent, instance: UsePDFInstance): void; + onClick?( + event: React.MouseEvent, + instance: UsePDFInstance, + ): void; } /** @@ -489,7 +499,10 @@ declare namespace ReactPDF { */ function usePDF(options: { document?: React.ReactElement; - }): [UsePDFInstance, (newDocument: React.ReactElement) => void]; + }): [ + UsePDFInstance, + (newDocument: React.ReactElement) => void, + ]; const Font: FontStore; @@ -510,7 +523,10 @@ declare namespace ReactPDF { toBlob: () => Promise; toBuffer: () => Promise; on: (event: 'change', callback: () => void) => void; - updateContainer: (document: React.ReactElement, callback?: () => void) => void; + updateContainer: ( + document: React.ReactElement, + callback?: () => void, + ) => void; removeListener: (event: 'change', callback: () => void) => void; }; diff --git a/packages/renderer/jest.config.js b/packages/renderer/jest.config.js index ba8842205..3a2416c8a 100644 --- a/packages/renderer/jest.config.js +++ b/packages/renderer/jest.config.js @@ -1,4 +1,4 @@ -module.exports = { +export default { testRegex: 'tests/.*?(test)\\.js$', setupFilesAfterEnv: ['/setup.jest.js'], transformIgnorePatterns: [ diff --git a/packages/renderer/package.json b/packages/renderer/package.json index ae0df8cf8..6f0f7be74 100644 --- a/packages/renderer/package.json +++ b/packages/renderer/package.json @@ -3,26 +3,33 @@ "version": "3.1.17", "license": "MIT", "description": "Create PDF files on the browser and server", - "types": "index.d.ts", "author": "Diego Muracciole ", "homepage": "https://github.com/diegomura/react-pdf#readme", - "main": "./lib/react-pdf.cjs.js", - "module": "./lib/react-pdf.es.js", + "type": "module", + "main": "./lib/react-pdf.cjs", + "module": "./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" + } + }, "repository": { "type": "git", "url": "https://github.com/diegomura/react-pdf.git", "directory": "packages/renderer" }, - "browser": { - "./lib/react-pdf.es.js": "./lib/react-pdf.browser.es.js", - "./lib/react-pdf.cjs.js": "./lib/react-pdf.browser.cjs.js" - }, "scripts": { "build": "rimraf ./lib && rollup -c", "watch": "rimraf ./lib && rollup -c -w", "size": "size-limit", "lint": "eslint src", - "test": "jest" + "test": "NODE_OPTIONS=\"--experimental-vm-modules\" jest" }, "dependencies": { "@babel/runtime": "^7.20.13", diff --git a/packages/renderer/rollup.config.js b/packages/renderer/rollup.config.js index 26daf54e4..af1ce6003 100644 --- a/packages/renderer/rollup.config.js +++ b/packages/renderer/rollup.config.js @@ -7,6 +7,7 @@ import ignore from 'rollup-plugin-ignore'; import { terser } from 'rollup-plugin-terser'; import sourceMaps from 'rollup-plugin-sourcemaps'; import commonjs from '@rollup/plugin-commonjs'; +import copy from 'rollup-plugin-copy'; import pkg from './package.json'; @@ -42,7 +43,7 @@ const getExternal = ({ browser }) => [ ...Object.keys(pkg.peerDependencies), ]; -const getPlugins = ({ browser, minify = false }) => [ +const getPlugins = ({ browser, declarationDests, minify = false }) => [ json(), sourceMaps(), ...(browser ? [ignore(['fs', 'path', 'url'])] : []), @@ -63,47 +64,73 @@ const getPlugins = ({ browser, minify = false }) => [ BROWSER: JSON.stringify(browser), }, }), + copy({ + targets: declarationDests.map(destPath => { + const [dest, rename] = destPath.split('/'); + return { src: 'index.d.ts', dest, rename }; + }), + }), ...(minify ? [terser()] : []), ]; const serverConfig = { input: nodeInput, output: [ - getESM({ file: 'lib/react-pdf.es.js' }), - getCJS({ file: 'lib/react-pdf.cjs.js' }), + getESM({ file: 'lib/react-pdf.js' }), + getCJS({ file: 'lib/react-pdf.cjs' }), ], external: getExternal({ browser: false }), - plugins: getPlugins({ browser: false }), + plugins: getPlugins({ + browser: false, + declarationDests: ['lib/react-pdf.d.ts', 'lib/react-pdf.d.cts'], + }), }; const serverProdConfig = { input: nodeInput, output: [ - getESM({ file: 'lib/react-pdf.es.min.js', sourcemap: false }), - getCJS({ file: 'lib/react-pdf.cjs.min.js', sourcemap: false }), + getESM({ file: 'lib/react-pdf.min.js', sourcemap: false }), + getCJS({ file: 'lib/react-pdf.min.cjs', sourcemap: false }), ], external: getExternal({ browser: false }), - plugins: getPlugins({ browser: false, minify: true }), + plugins: getPlugins({ + browser: false, + declarationDests: ['lib/react-pdf.min.d.ts', 'lib/react-pdf.min.d.cts'], + minify: true, + }), }; const browserConfig = { input: domInput, output: [ - getESM({ file: 'lib/react-pdf.browser.es.js' }), - getCJS({ file: 'lib/react-pdf.browser.cjs.js' }), + getESM({ file: 'lib/react-pdf.browser.js' }), + getCJS({ file: 'lib/react-pdf.browser.cjs' }), ], external: getExternal({ browser: true }), - plugins: getPlugins({ browser: true }), + plugins: getPlugins({ + browser: true, + declarationDests: [ + 'lib/react-pdf.browser.d.ts', + 'lib/react-pdf.browser.d.cts', + ], + }), }; const browserProdConfig = { input: domInput, output: [ - getESM({ file: 'lib/react-pdf.browser.es.min.js', sourcemap: false }), - getCJS({ file: 'lib/react-pdf.browser.cjs.min.js', sourcemap: false }), + getESM({ file: 'lib/react-pdf.browser.min.js', sourcemap: false }), + getCJS({ file: 'lib/react-pdf.browser.min.cjs', sourcemap: false }), ], external: getExternal({ browser: true }), - plugins: getPlugins({ browser: true, minify: true }), + plugins: getPlugins({ + browser: true, + declarationDests: [ + 'lib/react-pdf.browser.min.d.ts', + 'lib/react-pdf.browser.min.d.cts', + ], + minify: true, + }), }; export default [ diff --git a/packages/renderer/setup.jest.js b/packages/renderer/setup.jest.js index 2ba8418ab..928c95da0 100644 --- a/packages/renderer/setup.jest.js +++ b/packages/renderer/setup.jest.js @@ -1,5 +1,10 @@ -/* eslint-disable import/no-extraneous-dependencies */ -const { configureToMatchImageSnapshot } = require('jest-image-snapshot'); +import path from 'path'; +import url from 'url'; +import jestImageSnapshot from 'jest-image-snapshot'; + +const { configureToMatchImageSnapshot } = jestImageSnapshot; + +const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); // setup image matcher const toMatchImageSnapshot = configureToMatchImageSnapshot({ diff --git a/packages/renderer/src/index.js b/packages/renderer/src/index.js index 955d41a08..eaa59fcf4 100644 --- a/packages/renderer/src/index.js +++ b/packages/renderer/src/index.js @@ -4,7 +4,9 @@ import PDFDocument from '@react-pdf/pdfkit'; import layoutDocument from '@react-pdf/layout'; import createRenderer from './renderer'; -import { version } from '../package.json'; +import packageJson from '../package.json'; + +const { version } = packageJson; const fontStore = new FontStore(); diff --git a/packages/renderer/tests/components.test.js b/packages/renderer/tests/components.test.js index 35883748b..a18277d19 100644 --- a/packages/renderer/tests/components.test.js +++ b/packages/renderer/tests/components.test.js @@ -2,7 +2,7 @@ * @jest-environment ./tests/environment/jsdom.js */ -/* eslint-disable import/no-extraneous-dependencies */ +import { jest } from '@jest/globals'; import { render, waitFor, screen } from '@testing-library/react'; import { BlobProvider, diff --git a/packages/renderer/tests/debug.test.js b/packages/renderer/tests/debug.test.js index 511ea6c8f..0debde986 100644 --- a/packages/renderer/tests/debug.test.js +++ b/packages/renderer/tests/debug.test.js @@ -1,4 +1,4 @@ -import { Document, Page, View, Text, Font } from '..'; +import { Document, Page, View, Text, Font } from '@react-pdf/renderer'; import renderToImage from './renderComponent'; // pdf.js does not render default fonts in node and I use Open Sans (: diff --git a/packages/renderer/tests/dom.test.js b/packages/renderer/tests/dom.test.js index 117b04817..1ea379417 100644 --- a/packages/renderer/tests/dom.test.js +++ b/packages/renderer/tests/dom.test.js @@ -1,5 +1,4 @@ /* eslint-disable import/no-named-as-default-member */ - import ReactPDF from '../src/dom'; describe('dom', () => { diff --git a/packages/renderer/tests/emoji.test.js b/packages/renderer/tests/emoji.test.js index 333747b06..fae9c1ec2 100644 --- a/packages/renderer/tests/emoji.test.js +++ b/packages/renderer/tests/emoji.test.js @@ -1,5 +1,5 @@ +import { Document, Page, Text, Font } from '@react-pdf/renderer'; import renderToImage from './renderComponent'; -import { Document, Page, Text, Font } from '..'; describe('emoji', () => { test('should support builder function', async () => { diff --git a/packages/renderer/tests/environment/jsdom.js b/packages/renderer/tests/environment/jsdom.js index 7be5492c4..fc9d22eee 100644 --- a/packages/renderer/tests/environment/jsdom.js +++ b/packages/renderer/tests/environment/jsdom.js @@ -1,8 +1,7 @@ -/* eslint-disable import/no-extraneous-dependencies */ -const Environment = require('jest-environment-jsdom').default; -const { TextEncoder, TextDecoder } = require('util'); +import { TestEnvironment } from 'jest-environment-jsdom'; +import { TextEncoder, TextDecoder } from 'util'; -class CustomEnvironment extends Environment { +class CustomEnvironment extends TestEnvironment { async setup() { await super.setup(); @@ -25,4 +24,4 @@ class CustomEnvironment extends Environment { } } -module.exports = CustomEnvironment; +export default CustomEnvironment; diff --git a/packages/renderer/tests/flex.test.js b/packages/renderer/tests/flex.test.js index a487b8900..88e2111d2 100644 --- a/packages/renderer/tests/flex.test.js +++ b/packages/renderer/tests/flex.test.js @@ -1,5 +1,5 @@ /* eslint-disable react/no-array-index-key */ -import { Document, Page, View } from '..'; +import { Document, Page, View } from '@react-pdf/renderer'; import renderToImage from './renderComponent'; const mount = async children => { diff --git a/packages/renderer/tests/gap.test.js b/packages/renderer/tests/gap.test.js index 07315fed4..3c472e961 100644 --- a/packages/renderer/tests/gap.test.js +++ b/packages/renderer/tests/gap.test.js @@ -1,5 +1,5 @@ /* eslint-disable react/no-array-index-key */ -import { Document, Page, View } from '..'; +import { Document, Page, View } from '@react-pdf/renderer'; import renderToImage from './renderComponent'; const mount = async children => { diff --git a/packages/renderer/tests/link.test.js b/packages/renderer/tests/link.test.js index 0acdf4e04..300cfc638 100644 --- a/packages/renderer/tests/link.test.js +++ b/packages/renderer/tests/link.test.js @@ -1,4 +1,4 @@ -import { Document, Page, Link, Font, Text } from '..'; +import { Document, Page, Link, Font, Text } from '@react-pdf/renderer'; import renderToImage from './renderComponent'; // pdf.js does not render default fonts in node and I use Open Sans (: diff --git a/packages/renderer/tests/node.test.js b/packages/renderer/tests/node.test.js index e9e2f286d..13cb7db7f 100644 --- a/packages/renderer/tests/node.test.js +++ b/packages/renderer/tests/node.test.js @@ -1,10 +1,15 @@ /* eslint-disable import/no-named-as-default-member */ import fs from 'fs'; +import path from 'path'; +import url from 'url'; +import { jest } from '@jest/globals'; import ReactPDF from '../src/node'; const { Document, Page, View } = ReactPDF; +const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); + const TestDocument = ({ onRender }) => { return ( @@ -47,12 +52,12 @@ describe('node', () => { }); test('should render to file', async () => { - const path = `${__dirname}/test.pdf`; - await ReactPDF.renderToFile(, path); + const pdfPath = `${__dirname}/test.pdf`; + await ReactPDF.renderToFile(, pdfPath); - expect(fs.existsSync(path)).toBeTruthy(); + expect(fs.existsSync(pdfPath)).toBeTruthy(); - fs.unlinkSync(path); + fs.unlinkSync(pdfPath); }); test('should export font store', () => { diff --git a/packages/renderer/tests/pageWrap.test.js b/packages/renderer/tests/pageWrap.test.js index b4c9d620a..faadf9698 100644 --- a/packages/renderer/tests/pageWrap.test.js +++ b/packages/renderer/tests/pageWrap.test.js @@ -1,6 +1,13 @@ /* eslint-disable react/no-array-index-key */ +import { + Document, + Font, + Page, + Text, + Image, + StyleSheet, +} from '@react-pdf/renderer'; import renderToImage from './renderComponent'; -import { Document, Font, Page, Text, Image, StyleSheet } from '..'; const styles = StyleSheet.create({ body: { diff --git a/packages/renderer/tests/renderComponent.js b/packages/renderer/tests/renderComponent.js index 0ddeeb552..caab32097 100644 --- a/packages/renderer/tests/renderComponent.js +++ b/packages/renderer/tests/renderComponent.js @@ -1,10 +1,9 @@ -/* eslint-disable import/no-extraneous-dependencies */ /* eslint-disable no-param-reassign */ import Canvas from 'canvas'; -import * as pdfjs from 'pdfjs-dist/legacy/build/pdf'; +import pdfjs from 'pdfjs-dist/legacy/build/pdf'; -import { renderToBuffer } from '..'; +import { renderToBuffer } from '@react-pdf/renderer'; /** * copy-pasted code from diff --git a/packages/renderer/tests/resume.test.js b/packages/renderer/tests/resume.test.js index 1a32b5d4c..ab072dc77 100644 --- a/packages/renderer/tests/resume.test.js +++ b/packages/renderer/tests/resume.test.js @@ -1,6 +1,15 @@ /* eslint-disable react/no-array-index-key */ +import { + Link, + Text, + Font, + Page, + View, + Image, + Document, + StyleSheet, +} from '@react-pdf/renderer'; import renderToImage from './renderComponent'; -import { Link, Text, Font, Page, View, Image, Document, StyleSheet } from '..'; const headerStyles = StyleSheet.create({ container: { diff --git a/packages/renderer/tests/svg.test.js b/packages/renderer/tests/svg.test.js index 317746de8..f85e951ef 100644 --- a/packages/renderer/tests/svg.test.js +++ b/packages/renderer/tests/svg.test.js @@ -1,5 +1,5 @@ /* eslint-disable react/jsx-one-expression-per-line */ -import { Document, Page, Svg, Font, Text, Tspan } from '..'; +import { Document, Page, Svg, Font, Text, Tspan } from '@react-pdf/renderer'; import renderToImage from './renderComponent'; import { Tiger, Chart, Chart2, Gradients } from './svgs'; diff --git a/packages/renderer/tests/svgs.js b/packages/renderer/tests/svgs.js index 847c5d6f4..93a1c2c99 100644 --- a/packages/renderer/tests/svgs.js +++ b/packages/renderer/tests/svgs.js @@ -12,7 +12,7 @@ import { LinearGradient, RadialGradient, Stop, -} from '..'; +} from '@react-pdf/renderer'; export const Tiger = () => ( diff --git a/packages/renderer/tests/text.test.js b/packages/renderer/tests/text.test.js index a38cd07e7..cbaaad761 100644 --- a/packages/renderer/tests/text.test.js +++ b/packages/renderer/tests/text.test.js @@ -1,7 +1,15 @@ /* eslint-disable react/jsx-one-expression-per-line */ /* eslint-disable react/no-array-index-key */ +import { + Document, + Page, + View, + Text, + Link, + Font, + StyleSheet, +} from '@react-pdf/renderer'; import renderToImage from './renderComponent'; -import { Document, Page, View, Text, Link, Font, StyleSheet } from '..'; const styles = StyleSheet.create({ title: { diff --git a/packages/renderer/tests/transform.test.js b/packages/renderer/tests/transform.test.js index 1253c0223..5c50d3fac 100644 --- a/packages/renderer/tests/transform.test.js +++ b/packages/renderer/tests/transform.test.js @@ -1,4 +1,4 @@ -import { Document, Page, View } from '..'; +import { Document, Page, View } from '@react-pdf/renderer'; import renderToImage from './renderComponent'; const TestDocument = ({ transform, width = 20, height = 20 }) => { diff --git a/packages/renderer/tests/usePDF.test.js b/packages/renderer/tests/usePDF.test.js index 47da78ea8..c685213f9 100644 --- a/packages/renderer/tests/usePDF.test.js +++ b/packages/renderer/tests/usePDF.test.js @@ -2,7 +2,6 @@ * @jest-environment ./tests/environment/jsdom.js */ -/* eslint-disable import/no-extraneous-dependencies */ import { renderHook, waitFor, act } from '@testing-library/react'; import { usePDF, Document, Page, Text } from '../src/dom'; diff --git a/packages/stylesheet/babel.config.js b/packages/stylesheet/babel.config.js index 27f83582f..02d1cbbdb 100644 --- a/packages/stylesheet/babel.config.js +++ b/packages/stylesheet/babel.config.js @@ -1 +1 @@ -module.exports = { extends: '../../babel.config.js' }; +export default { extends: '../../babel.config.js' }; diff --git a/packages/stylesheet/jest.config.js b/packages/stylesheet/jest.config.js index 1a99b7295..40b1faa8e 100644 --- a/packages/stylesheet/jest.config.js +++ b/packages/stylesheet/jest.config.js @@ -1,3 +1,3 @@ -module.exports = { +export default { testRegex: 'tests/.*?(test)\\.js$', }; diff --git a/packages/stylesheet/package.json b/packages/stylesheet/package.json index 7988433df..009fe5322 100644 --- a/packages/stylesheet/package.json +++ b/packages/stylesheet/package.json @@ -5,15 +5,23 @@ "description": "A styles engine for Node and the browser", "author": "Diego Muracciole ", "homepage": "https://github.com/diegomura/react-pdf#readme", - "main": "lib/index.cjs.js", - "module": "lib/index.es.js", + "type": "module", + "main": "./lib/index.cjs", + "module": "./lib/index.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", "directory": "packages/stylesheet" }, "scripts": { - "test": "jest", + "test": "NODE_OPTIONS=\"--experimental-vm-modules\" jest", "build": "rimraf ./lib && rollup -c", "watch": "rimraf ./lib && rollup -c -w" }, diff --git a/packages/stylesheet/rollup.config.js b/packages/stylesheet/rollup.config.js index 6a28aba35..c53b565ae 100644 --- a/packages/stylesheet/rollup.config.js +++ b/packages/stylesheet/rollup.config.js @@ -34,10 +34,7 @@ const getPlugins = () => [ const config = { input, - output: [ - getESM({ file: 'lib/index.es.js' }), - getCJS({ file: 'lib/index.cjs.js' }), - ], + output: [getESM({ file: 'lib/index.js' }), getCJS({ file: 'lib/index.cjs' })], external: getExternal(), plugins: getPlugins(), }; diff --git a/packages/stylesheet/src/expand/boxModel.js b/packages/stylesheet/src/expand/boxModel.js index 373d8cca7..e2d398d24 100644 --- a/packages/stylesheet/src/expand/boxModel.js +++ b/packages/stylesheet/src/expand/boxModel.js @@ -1,6 +1,10 @@ /* eslint-disable no-plusplus */ -import parse from 'postcss-value-parser/lib/parse'; -import parseUnit from 'postcss-value-parser/lib/unit'; +// This file is ran directly with Node - needs to have .js extension +// eslint-disable-next-line import/extensions +import parse from 'postcss-value-parser/lib/parse.js'; +// This file is ran directly with Node - needs to have .js extension +// eslint-disable-next-line import/extensions +import parseUnit from 'postcss-value-parser/lib/unit.js'; const BOX_MODEL_UNITS = 'px,in,mm,cm,pt,%,vw,vh'; diff --git a/packages/svgkit/babel.config.js b/packages/svgkit/babel.config.js index 27f83582f..02d1cbbdb 100644 --- a/packages/svgkit/babel.config.js +++ b/packages/svgkit/babel.config.js @@ -1 +1 @@ -module.exports = { extends: '../../babel.config.js' }; +export default { extends: '../../babel.config.js' }; diff --git a/packages/svgkit/package.json b/packages/svgkit/package.json index 9091c136a..8b9b8e73e 100644 --- a/packages/svgkit/package.json +++ b/packages/svgkit/package.json @@ -3,6 +3,7 @@ "license": "MIT", "version": "2.2.4", "description": "A SVG generation library for Node.js and browser", + "type": "module", "main": "./lib/index.js", "repository": { "type": "git", @@ -13,7 +14,7 @@ "Diego Muracciole " ], "scripts": { - "test": "jest", + "test": "NODE_OPTIONS=\"--experimental-vm-modules\" jest", "build": "rimraf ./lib && babel src --out-dir lib", "watch": "rimraf ./lib && babel src --out-dir lib --watch" }, diff --git a/packages/textkit/babel.config.js b/packages/textkit/babel.config.js index 831adcadc..defa6f8c2 100644 --- a/packages/textkit/babel.config.js +++ b/packages/textkit/babel.config.js @@ -1,3 +1,3 @@ -module.exports = { +export default { extends: '../../babel.config.js', }; diff --git a/packages/textkit/package.json b/packages/textkit/package.json index f9395db05..e279d7496 100644 --- a/packages/textkit/package.json +++ b/packages/textkit/package.json @@ -3,8 +3,16 @@ "license": "MIT", "version": "4.2.1", "description": "An advanced text layout framework", - "main": "./lib/textkit.cjs.js", - "module": "./lib/textkit.es.js", + "type": "module", + "main": "./lib/textkit.cjs", + "module": "./lib/textkit.js", + "exports": { + ".": { + "import": "./lib/textkit.js", + "require": "./lib/textkit.cjs", + "default": "./lib/textkit.js" + } + }, "repository": { "type": "git", "url": "https://github.com/diegomura/react-pdf.git", @@ -15,7 +23,7 @@ "Diego Muracciole " ], "scripts": { - "test": "jest", + "test": "NODE_OPTIONS=\"--experimental-vm-modules\" jest", "build": "rimraf ./lib && rollup -c", "watch": "rimraf ./lib && rollup -c -w" }, diff --git a/packages/textkit/rollup.config.js b/packages/textkit/rollup.config.js index d3cc8fa55..c3945267f 100644 --- a/packages/textkit/rollup.config.js +++ b/packages/textkit/rollup.config.js @@ -30,8 +30,8 @@ const getPlugins = () => [localResolve(), babel(babelConfig())]; const config = { input, output: [ - getESM({ file: 'lib/textkit.es.js' }), - getCJS({ file: 'lib/textkit.cjs.js' }), + getESM({ file: 'lib/textkit.js' }), + getCJS({ file: 'lib/textkit.cjs' }), ], external: getExternal(), plugins: getPlugins(), diff --git a/packages/textkit/src/engines/wordHyphenation/index.js b/packages/textkit/src/engines/wordHyphenation/index.js index 4fa45e6b1..4de04b3a0 100644 --- a/packages/textkit/src/engines/wordHyphenation/index.js +++ b/packages/textkit/src/engines/wordHyphenation/index.js @@ -1,5 +1,7 @@ import hyphen from 'hyphen'; -import pattern from 'hyphen/patterns/en-us'; +// This file is ran directly with Node - needs to have .js extension +// eslint-disable-next-line import/extensions +import pattern from 'hyphen/patterns/en-us.js'; import { isNil } from '@react-pdf/fns'; const SOFT_HYPHEN = '\u00ad'; diff --git a/packages/textkit/tests/engines/wordHyphenation.test.js b/packages/textkit/tests/engines/wordHyphenation.test.js index 7f72c789e..701ca97c0 100644 --- a/packages/textkit/tests/engines/wordHyphenation.test.js +++ b/packages/textkit/tests/engines/wordHyphenation.test.js @@ -1,6 +1,4 @@ -import hyphen from 'hyphen'; - -jest.mock('hyphen'); +import { jest } from '@jest/globals'; const hyphenator = jest.fn(v => { if (v === '') return ''; @@ -11,9 +9,10 @@ const hyphenator = jest.fn(v => { return v; }); -hyphen.mockReturnValue(hyphenator); +jest.unstable_mockModule('hyphen', () => ({ default: () => hyphenator })); -const wordHyphenation = require('../../src/engines/wordHyphenation').default; +const wordHyphenation = (await import('../../src/engines/wordHyphenation')) + .default; const instance = wordHyphenation({}); diff --git a/packages/textkit/tests/glyph/fromCodePoint.test.js b/packages/textkit/tests/glyph/fromCodePoint.test.js index 39d118565..f8fe3837c 100644 --- a/packages/textkit/tests/glyph/fromCodePoint.test.js +++ b/packages/textkit/tests/glyph/fromCodePoint.test.js @@ -1,3 +1,4 @@ +import { jest } from '@jest/globals'; import fromCodePoint from '../../src/glyph/fromCodePoint'; const font = { diff --git a/packages/textkit/tests/internal/fontSubstitutionEngine.js b/packages/textkit/tests/internal/fontSubstitutionEngine.js index ea24d88df..c93529c2a 100644 --- a/packages/textkit/tests/internal/fontSubstitutionEngine.js +++ b/packages/textkit/tests/internal/fontSubstitutionEngine.js @@ -1,3 +1,5 @@ +import { jest } from '@jest/globals'; + /** * Test font substitution based on the string 'Lorem' * Returns empry if no runs present, or arbitrary font substitution otherwise diff --git a/packages/textkit/tests/internal/scriptItemizer.js b/packages/textkit/tests/internal/scriptItemizer.js index ca633e85c..e4cbbb1aa 100644 --- a/packages/textkit/tests/internal/scriptItemizer.js +++ b/packages/textkit/tests/internal/scriptItemizer.js @@ -1,3 +1,5 @@ +import { jest } from '@jest/globals'; + /** * Test script itemizer based on the string 'Lorem' * Returns empty if no runs present, or arbitrary script itemization otherwise diff --git a/packages/textkit/tests/layout/wrapWords.test.js b/packages/textkit/tests/layout/wrapWords.test.js index e905aaa1d..caec35ab4 100644 --- a/packages/textkit/tests/layout/wrapWords.test.js +++ b/packages/textkit/tests/layout/wrapWords.test.js @@ -1,3 +1,4 @@ +import { jest } from '@jest/globals'; import wrapWords from '../../src/layout/wrapWords'; const emptyInstance = wrapWords({}, {}); diff --git a/yarn.lock b/yarn.lock index 3b4a5feee..83cfb066d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -280,19 +280,12 @@ chalk "^2.4.2" js-tokens "^4.0.0" -"@babel/node@^7.20.7": - version "7.20.7" - resolved "https://registry.yarnpkg.com/@babel/node/-/node-7.20.7.tgz#609be7f841893e24931b7910263babfde84040a9" - integrity sha512-AQt3gVcP+fpFuoFn4FmIW/+5JovvEoA9og4Y1LrRw0pv3jkl4tujZMMy3X/3ugjLrEy3k1aNywo3JIl3g+jVXQ== - dependencies: - "@babel/register" "^7.18.9" - commander "^4.0.1" - core-js "^3.26.0" - node-environment-flags "^1.0.5" - regenerator-runtime "^0.13.11" - v8flags "^3.1.1" +"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.20.7", "@babel/parser@^7.7.0": + version "7.22.4" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.22.4.tgz#a770e98fd785c231af9d93f6459d36770993fb32" + integrity sha512-VLLsx06XkEYqBtE5YGPwfSGwfrjnyPP5oiGty3S8pQLFDFLaS8VwWSIxkTXpcvr5zeYLE6+MBNl2npl/YnfofA== -"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.20.7", "@babel/parser@^7.22.15", "@babel/parser@^7.23.6", "@babel/parser@^7.7.0": +"@babel/parser@^7.22.15", "@babel/parser@^7.23.6": version "7.23.6" resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.23.6.tgz#ba1c9e512bda72a47e285ae42aff9d2a635a9e3b" integrity sha512-Z2uID7YJ7oNvAI20O9X0bblw7Qqs8Q2hFy0R9tAfnfLkp5MW0UH9eUvnDSnFwKZ0AvgS1ucqR4KzvVHgnke1VQ== @@ -1001,17 +994,6 @@ "@babel/plugin-transform-react-jsx-development" "^7.18.6" "@babel/plugin-transform-react-pure-annotations" "^7.18.6" -"@babel/register@^7.18.9": - version "7.18.9" - resolved "https://registry.yarnpkg.com/@babel/register/-/register-7.18.9.tgz#1888b24bc28d5cc41c412feb015e9ff6b96e439c" - integrity sha512-ZlbnXDcNYHMR25ITwwNKT88JiaukkdVj/nG7r3wnuXkOTHc60Uy05PwMCPre0hSkY68E6zK3xz+vUJSP2jWmcw== - dependencies: - clone-deep "^4.0.1" - find-cache-dir "^2.0.0" - make-dir "^2.1.0" - pirates "^4.0.5" - source-map-support "^0.5.16" - "@babel/regjsgen@^0.8.0": version "0.8.0" resolved "https://registry.yarnpkg.com/@babel/regjsgen/-/regjsgen-0.8.0.tgz#f0ba69b075e1f05fb2825b7fad991e7adbb18310" @@ -2532,6 +2514,21 @@ resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4" integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw== +"@types/fs-extra@^8.0.1": + version "8.1.5" + resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-8.1.5.tgz#33aae2962d3b3ec9219b5aca2555ee00274f5927" + integrity sha512-0dzKcwO+S8s2kuF5Z9oUWatQJj5Uq/iqphEtE3GQJVRRYm/tD1LglU2UnXi2A8jLq5umkGouOXOR9y0n613ZwQ== + dependencies: + "@types/node" "*" + +"@types/glob@^7.1.1": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb" + integrity sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA== + dependencies: + "@types/minimatch" "*" + "@types/node" "*" + "@types/graceful-fs@^4.1.3": version "4.1.6" resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.6.tgz#e14b2576a1c25026b7f02ede1de3b84c3a1efeae" @@ -2584,6 +2581,11 @@ resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4= +"@types/minimatch@*": + version "5.1.2" + resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-5.1.2.tgz#07508b45797cb81ec3f273011b054cd0755eddca" + integrity sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA== + "@types/minimatch@^3.0.3": version "3.0.5" resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.5.tgz#1001cc5e6a3704b83c236027e77f2f58ea010f40" @@ -3718,7 +3720,7 @@ cliui@^8.0.1: strip-ansi "^6.0.1" wrap-ansi "^7.0.0" -clone-deep@4.0.1, clone-deep@^4.0.1: +clone-deep@4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/clone-deep/-/clone-deep-4.0.1.tgz#c19fd9bdbbf85942b4fd979c84dcf7d5f07c2387" integrity sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ== @@ -3794,6 +3796,11 @@ color-support@^1.1.3: resolved "https://registry.yarnpkg.com/color-support/-/color-support-1.1.3.tgz#93834379a1cc9a0c61f82f52f0d04322251bd5a2" integrity sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg== +colorette@^1.1.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.4.0.tgz#5190fbb87276259a86ad700bff2c6d6faa3fca40" + integrity sha512-Y2oEozpomLn7Q3HFP7dpww7AtMJplbM9lGZP6RDfHqmbeRjiwRg4n6VM6j4KLmRke85uWEI7JqF17f3pqdRA0g== + colorette@^2.0.16: version "2.0.16" resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.16.tgz#713b9af84fdb000139f04546bd4a93f62a5085da" @@ -3972,11 +3979,6 @@ core-js-pure@^3.0.0: resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.10.0.tgz#dab9d6b141779b622b40567e7a536d2276646c15" integrity sha512-CC582enhrFZStO4F8lGI7QL3SYx7/AIRc+IdSi3btrQGrVsTawo5K/crmKbRrQ+MOMhNX4v+PATn0k2NN6wI7A== -core-js@^3.26.0: - version "3.28.0" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.28.0.tgz#ed8b9e99c273879fdfff0edfc77ee709a5800e4a" - integrity sha512-GiZn9D4Z/rSYvTeg1ljAIsEqFm0LaN9gVtwDCrKL80zHtS31p9BAjmTxVqTQDMpwlMolJZOFntUG2uwyj7DAqw== - core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" @@ -4953,7 +4955,7 @@ fast-fifo@^1.1.0, fast-fifo@^1.2.0: resolved "https://registry.yarnpkg.com/fast-fifo/-/fast-fifo-1.3.2.tgz#286e31de96eb96d38a97899815740ba2a4f3640c" integrity sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ== -fast-glob@^3.2.9, fast-glob@^3.3.2: +fast-glob@^3.0.3, fast-glob@^3.2.9, fast-glob@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129" integrity sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow== @@ -5023,15 +5025,6 @@ fill-range@^7.0.1: dependencies: to-regex-range "^5.0.1" -find-cache-dir@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-2.1.0.tgz#8d0f94cd13fe43c6c7c261a0d86115ca918c05f7" - integrity sha512-Tq6PixE0w/VMFfCgbONnkiQIVol/JJL7nRMi20fqzA4NRs9AfeqMGeRdPi3wIhYkxjeBaWh2rxwapn5Tu3IqOQ== - dependencies: - commondir "^1.0.1" - make-dir "^2.0.0" - pkg-dir "^3.0.0" - find-chrome-bin@2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/find-chrome-bin/-/find-chrome-bin-2.0.1.tgz#e91a5496b7118bb9e3b4c306b25bda9616b572cb" @@ -5046,13 +5039,6 @@ find-up@^2.0.0, find-up@^2.1.0: dependencies: locate-path "^2.0.0" -find-up@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" - integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg== - dependencies: - locate-path "^3.0.0" - find-up@^4.0.0, find-up@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" @@ -5466,6 +5452,20 @@ globals@^12.1.0: dependencies: type-fest "^0.8.1" +globby@10.0.1: + version "10.0.1" + resolved "https://registry.yarnpkg.com/globby/-/globby-10.0.1.tgz#4782c34cb75dd683351335c5829cc3420e606b22" + integrity sha512-sSs4inE1FB2YQiymcmTv6NWENryABjUNPeWhOvmn4SjtKybglsyPZxFB3U1/+L1bYi0rNZDqCLlHyLYDl1Pq5A== + dependencies: + "@types/glob" "^7.1.1" + array-union "^2.1.0" + dir-glob "^3.0.1" + fast-glob "^3.0.3" + glob "^7.1.3" + ignore "^5.1.1" + merge2 "^1.2.3" + slash "^3.0.0" + globby@11.1.0, globby@^11.0.0: version "11.1.0" resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" @@ -5587,13 +5587,6 @@ hasown@^2.0.0: dependencies: function-bind "^1.1.2" -homedir-polyfill@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz#743298cef4e5af3e194161fbadcc2151d3a058e8" - integrity sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA== - dependencies: - parse-passwd "^1.0.0" - hosted-git-info@^2.1.4: version "2.8.8" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488" @@ -5766,7 +5759,7 @@ ignore@^4.0.6: resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== -ignore@^5.0.4, ignore@^5.2.4: +ignore@^5.0.4, ignore@^5.1.1, ignore@^5.2.4: version "5.3.0" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.0.tgz#67418ae40d34d6999c95ff56016759c718c82f78" integrity sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg== @@ -6082,6 +6075,11 @@ is-plain-object@^2.0.4: dependencies: isobject "^3.0.1" +is-plain-object@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-3.0.1.tgz#662d92d24c0aa4302407b0d45d21f2251c85f85b" + integrity sha512-Xnpx182SBMrr/aBik8y+GuR4U1L9FqMSojwDQwPMmxyC6bvEqly9UBCxhauBF5vNh2gwWJNX6oDV7O+OM4z34g== + is-plain-object@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344" @@ -7122,14 +7120,6 @@ locate-path@^2.0.0: p-locate "^2.0.0" path-exists "^3.0.0" -locate-path@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" - integrity sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A== - dependencies: - p-locate "^3.0.0" - path-exists "^3.0.0" - locate-path@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" @@ -7245,7 +7235,7 @@ make-dir@4.0.0: dependencies: semver "^7.5.3" -make-dir@^2.0.0, make-dir@^2.1.0: +make-dir@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5" integrity sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA== @@ -7359,7 +7349,7 @@ merge-stream@^2.0.0: resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== -merge2@^1.3.0, merge2@^1.4.1: +merge2@^1.2.3, merge2@^1.3.0, merge2@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== @@ -7659,14 +7649,6 @@ nice-try@^1.0.4: resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== -node-environment-flags@^1.0.5: - version "1.0.6" - resolved "https://registry.yarnpkg.com/node-environment-flags/-/node-environment-flags-1.0.6.tgz#a30ac13621f6f7d674260a54dede048c3982c088" - integrity sha512-5Evy2epuL+6TM0lCQGpFIj6KwiEsGh1SrHUhTbNX+sLbBtjidPZFAnVK9y5yU1+h//RitLbRHTIMyxQPtxMdHw== - dependencies: - object.getownpropertydescriptors "^2.0.3" - semver "^5.7.0" - node-fetch@2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.1.2.tgz#ab884e8e7e57e38a944753cec706f788d1768bb5" @@ -8047,15 +8029,6 @@ object.fromentries@^2.0.4: es-abstract "^1.18.0-next.2" has "^1.0.3" -object.getownpropertydescriptors@^2.0.3: - version "2.1.2" - resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.2.tgz#1bd63aeacf0d5d2d2f31b5e393b03a7c601a23f7" - integrity sha512-WtxeKSzfBjlzL+F9b7M7hewDzMwy+C8NRssHd1YrNlzHzIDrXcXiNOMrezdAEM4UXixgV+vvnyBeN7Rygl2ttQ== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" - es-abstract "^1.18.0-next.2" - object.values@^1.1.1, object.values@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.1.3.tgz#eaa8b1e17589f02f698db093f7c62ee1699742ee" @@ -8145,7 +8118,7 @@ p-limit@^1.1.0: dependencies: p-try "^1.0.0" -p-limit@^2.0.0, p-limit@^2.2.0: +p-limit@^2.2.0: version "2.3.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== @@ -8166,13 +8139,6 @@ p-locate@^2.0.0: dependencies: p-limit "^1.1.0" -p-locate@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4" - integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ== - dependencies: - p-limit "^2.0.0" - p-locate@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" @@ -8335,11 +8301,6 @@ parse-json@^5.0.0, parse-json@^5.2.0: json-parse-even-better-errors "^2.3.0" lines-and-columns "^1.1.6" -parse-passwd@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/parse-passwd/-/parse-passwd-1.0.0.tgz#6d5b934a456993b23d37f40a382d6f1666a8e5c6" - integrity sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY= - parse-path@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/parse-path/-/parse-path-7.0.0.tgz#605a2d58d0a749c8594405d8cc3a2bf76d16099b" @@ -8472,7 +8433,7 @@ pify@^4.0.1: resolved "https://registry.yarnpkg.com/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231" integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g== -pirates@^4.0.4, pirates@^4.0.5: +pirates@^4.0.4: version "4.0.5" resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.5.tgz#feec352ea5c3268fb23a37c702ab1699f35a5f3b" integrity sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ== @@ -8491,13 +8452,6 @@ pkg-dir@^2.0.0: dependencies: find-up "^2.1.0" -pkg-dir@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-3.0.0.tgz#2749020f239ed990881b1f71210d51eb6523bea3" - integrity sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw== - dependencies: - find-up "^3.0.0" - pkg-dir@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" @@ -9108,6 +9062,17 @@ rimraf@^4.4.1: dependencies: glob "^9.2.0" +rollup-plugin-copy@^3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/rollup-plugin-copy/-/rollup-plugin-copy-3.5.0.tgz#7ffa2a7a8303e143876fa64fb5eed9022d304eeb" + integrity sha512-wI8D5dvYovRMx/YYKtUNt3Yxaw4ORC9xo6Gt9t22kveWz1enG9QrhVlagzwrxSC455xD1dHMKhIJkbsQ7d48BA== + dependencies: + "@types/fs-extra" "^8.0.1" + colorette "^1.1.0" + fs-extra "^8.1.0" + globby "10.0.1" + is-plain-object "^3.0.0" + rollup-plugin-ignore@^1.0.10: version "1.0.10" resolved "https://registry.yarnpkg.com/rollup-plugin-ignore/-/rollup-plugin-ignore-1.0.10.tgz#0b8453ebf977fca1b4b0634062dded45288bf764" @@ -9256,7 +9221,7 @@ semver-compare@^1.0.0: resolved "https://registry.yarnpkg.com/semver-compare/-/semver-compare-1.0.0.tgz#0dee216a1c941ab37e9efb1788f6afc5ff5537fc" integrity sha1-De4hahyUGrN+nvsXiPavxf9VN/w= -"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0, semver@^5.6.0, semver@^5.7.0: +"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0, semver@^5.6.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== @@ -9528,7 +9493,7 @@ source-map-support@0.5.13: buffer-from "^1.0.0" source-map "^0.6.0" -source-map-support@^0.5.16, source-map-support@~0.5.20: +source-map-support@~0.5.20: version "0.5.21" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== @@ -10356,13 +10321,6 @@ v8-to-istanbul@^9.0.1: "@types/istanbul-lib-coverage" "^2.0.1" convert-source-map "^1.6.0" -v8flags@^3.1.1: - version "3.2.0" - resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-3.2.0.tgz#b243e3b4dfd731fa774e7492128109a0fe66d656" - integrity sha512-mH8etigqMfiGWdeXpaaqGfs6BndypxusHHcv2qSHyZkGEznCd/qAXCWWRzeowtL54147cktFOC4P5y+kl8d8Jg== - dependencies: - homedir-polyfill "^1.0.1" - validate-npm-package-license@3.0.4, validate-npm-package-license@^3.0.1, validate-npm-package-license@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a"