-
Notifications
You must be signed in to change notification settings - Fork 703
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: flag esm build + view component client only, simplify rollup config
- Loading branch information
Showing
6 changed files
with
271 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import path from 'path' | ||
import babel from '@rollup/plugin-babel' | ||
import resolve 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 preserveDirectives from 'rollup-plugin-preserve-directives' | ||
|
||
const root = process.platform === 'win32' ? path.resolve('/') : '/' | ||
const external = (id) => !id.startsWith('.') && !id.startsWith(root) | ||
const extensions = ['.js', '.jsx', '.ts', '.tsx', '.json'] | ||
|
||
function getBabelOptions({ useESModules }) { | ||
return { | ||
babelrc: false, | ||
extensions, | ||
exclude: '**/node_modules/**', | ||
babelHelpers: 'runtime', | ||
presets: [ | ||
[ | ||
'@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', | ||
], | ||
bugfixes: true, | ||
loose: true, | ||
modules: false, | ||
targets: '> 1%, not dead, not ie 11, not op_mini all', | ||
}, | ||
], | ||
'@babel/preset-react', | ||
'@babel/preset-typescript', | ||
], | ||
plugins: [ | ||
'@babel/plugin-proposal-nullish-coalescing-operator', | ||
['@babel/transform-runtime', { regenerator: false, useESModules }], | ||
], | ||
} | ||
} | ||
|
||
function onwarn(warning, warn) { | ||
if (warning.code === 'MODULE_LEVEL_DIRECTIVE' && warning.message.includes('use client')) return | ||
warn(warning) | ||
} | ||
|
||
export default [ | ||
{ | ||
onwarn, | ||
input: `./src/index.ts`, | ||
output: { dir: `dist`, format: 'esm', preserveModules: true }, | ||
external, | ||
plugins: [ | ||
json(), | ||
glslify(), | ||
babel(getBabelOptions({ useESModules: true })), | ||
resolve({ extensions }), | ||
preserveDirectives(), | ||
], | ||
}, | ||
{ | ||
onwarn, | ||
input: ['src/**/*.ts', 'src/**/*.tsx', '!src/index.ts'], | ||
output: { dir: `dist`, format: 'cjs', preserveModules: true }, | ||
external, | ||
plugins: [ | ||
multiInput.default({ | ||
transformOutputPath: (output) => output.replace(/\.[^/.]+$/, '.cjs.js'), | ||
}), | ||
json(), | ||
glslify(), | ||
babel(getBabelOptions({ useESModules: false })), | ||
resolve({ extensions }), | ||
terser(), | ||
preserveDirectives(), | ||
], | ||
}, | ||
{ | ||
onwarn, | ||
input: `./src/index.ts`, | ||
output: { file: `dist/index.cjs.js`, format: 'cjs' }, | ||
external, | ||
plugins: [json(), glslify(), babel(getBabelOptions({ useESModules: false })), resolve({ extensions }), terser()], | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
'use client' | ||
|
||
export * from './web' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
ce3eb7e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
drei – ./
drei-git-master-pmndrs.vercel.app
drei-pmndrs.vercel.app
drei.vercel.app
drei.react-spring.io
drei.pmnd.rs