Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rollup 4 upgrade #2175

Merged
merged 2 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,12 @@
},
"devDependencies": {
"@babel/core": "^7.26.0",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
"@babel/plugin-transform-class-properties": "^7.25.9",
"@babel/plugin-transform-logical-assignment-operators": "^7.25.9",
"@babel/plugin-transform-modules-commonjs": "^7.25.9",
"@babel/plugin-transform-nullish-coalescing-operator": "^7.25.9",
"@babel/plugin-transform-numeric-separator": "^7.25.9",
"@babel/plugin-transform-optional-chaining": "^7.25.9",
"@babel/plugin-transform-runtime": "^7.25.9",
"@babel/preset-env": "^7.26.0",
"@babel/preset-react": "^7.25.9",
Expand All @@ -84,10 +87,10 @@
"@eslint/js": "^9.14.0",
"@playwright/test": "^1.45.2",
"@react-three/fiber": "^8.0.8",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^19.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-terser": "^0.4.4",
"@storybook/addon-actions": "^8.4.1",
"@storybook/addon-controls": "^8.4.1",
"@storybook/addon-essentials": "^8.4.1",
Expand Down Expand Up @@ -119,11 +122,10 @@
"pretty-quick": "^4.0.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"rimraf": "^3.0.2",
"rollup": "^2.79.2",
"rollup-plugin-glslify": "^1.3.0",
"rimraf": "^6.0.1",
"rollup": "^4.24.3",
"rollup-plugin-glslify": "^1.3.1",
"rollup-plugin-multi-input": "^1.5.0",
"rollup-plugin-terser": "^7.0.2",
"semantic-release": "^24.2.0",
"serve": "^14.2.4",
"storybook": "^8.4.1",
Expand Down
41 changes: 23 additions & 18 deletions rollup.config.js → rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import path from 'path'
import babel from '@rollup/plugin-babel'
import resolve from '@rollup/plugin-node-resolve'
import { babel } from '@rollup/plugin-babel'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import json from '@rollup/plugin-json'
import glslify from 'rollup-plugin-glslify'
import multiInput from 'rollup-plugin-multi-input'
import { terser } from 'rollup-plugin-terser'
import terser from '@rollup/plugin-terser'

const root = process.platform === 'win32' ? path.resolve('/') : '/'
const external = (id) => !id.startsWith('.') && !id.startsWith(root)
const extensions = ['.js', '.jsx', '.ts', '.tsx', '.json']

const getBabelOptions = ({ useESModules }) => ({
const getBabelOptions = ({ useESModules }, targets = '> 1%, not dead, not ie 11, not op_mini all') => ({
babelrc: false,
extensions,
exclude: '**/node_modules/**',
Expand All @@ -20,24 +20,24 @@ const getBabelOptions = ({ useESModules }) => ({
'@babel/preset-env',
{
include: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-nullish-coalescing-operator',
'@babel/plugin-proposal-numeric-separator',
'@babel/plugin-proposal-logical-assignment-operators',
'@babel/plugin-transform-class-properties',
'@babel/plugin-transform-optional-chaining',
'@babel/plugin-transform-nullish-coalescing-operator',
'@babel/plugin-transform-numeric-separator',
'@babel/plugin-transform-logical-assignment-operators',
],
bugfixes: true,
loose: true,
modules: false,
targets: '> 1%, not dead, not ie 11, not op_mini all',
targets,
},
],
'@babel/preset-react',
'@babel/preset-typescript',
],
plugins: [
'@babel/plugin-proposal-nullish-coalescing-operator',
['@babel/transform-runtime', { regenerator: false, useESModules }],
'@babel/plugin-transform-nullish-coalescing-operator',
['@babel/plugin-transform-runtime', { regenerator: false, useESModules }],
],
})

Expand All @@ -51,20 +51,19 @@ export default [
json(),
glslify(),
babel(getBabelOptions({ useESModules: true }, '>1%, not dead, not ie 11, not op_mini all')),
resolve({ extensions }),
nodeResolve({ extensions }),
],
},
{
input: `./src/index.ts`,
output: { dir: `dist`, format: 'esm' },
output: { dir: `dist`, format: 'esm', preserveModules: true },
external,
plugins: [
json(),
glslify(),
babel(getBabelOptions({ useESModules: true }, '>1%, not dead, not ie 11, not op_mini all')),
resolve({ extensions }),
nodeResolve({ extensions }),
],
preserveModules: true,
},
{
input: ['src/**/*.ts', 'src/**/*.tsx', '!src/index.ts'],
Expand All @@ -77,14 +76,20 @@ export default [
json(),
glslify(),
babel(getBabelOptions({ useESModules: false })),
resolve({ extensions }),
nodeResolve({ extensions }),
terser(),
],
},
{
input: `./src/index.ts`,
output: { file: `dist/index.cjs.js`, format: 'cjs' },
external,
plugins: [json(), glslify(), babel(getBabelOptions({ useESModules: false })), resolve({ extensions }), terser()],
plugins: [
json(),
glslify(),
babel(getBabelOptions({ useESModules: false })),
nodeResolve({ extensions }),
terser(),
],
},
]
Loading