Created
January 28, 2020 21:36
-
-
Save atomicpages/390f1f2c917a1248c10a945764345919 to your computer and use it in GitHub Desktop.
Example of the react-rnd packaging issue
This file contains hidden or 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
import * as React from "react"; | |
import ReactDOM from "react-dom"; | |
import { Rnd } from "react-rnd"; | |
function App() { | |
return ( | |
<Rnd | |
default={{ | |
x: 0, | |
y: 0, | |
width: 320, | |
height: 200 | |
}} | |
> | |
Rnd | |
</Rnd> | |
); | |
} | |
ReactDOM.render(<App />, document.getElementById("root")); |
This file contains hidden or 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
{ | |
"name": "rollup_test", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"devDependencies": { | |
"@babel/core": "^7.8.3", | |
"@babel/preset-env": "^7.8.3", | |
"@babel/preset-react": "^7.8.3", | |
"@rollup/plugin-commonjs": "^11.0.1", | |
"@rollup/plugin-node-resolve": "^7.0.0", | |
"rollup": "^1.30.1", | |
"rollup-plugin-babel": "^4.3.3" | |
}, | |
"dependencies": { | |
"core-js": "^3.6.4", | |
"react": "^16.12.0", | |
"react-dom": "^16.12.0", | |
"react-rnd": "^10.1.4" | |
} | |
} |
This file contains hidden or 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
import resolve from '@rollup/plugin-node-resolve'; | |
import commonjs from '@rollup/plugin-commonjs'; | |
import babel from 'rollup-plugin-babel'; | |
import pkg from './package.json'; | |
export default { | |
input: './index.js', | |
external: ['react', 'react-dom'], | |
globals: { | |
'react': 'React', | |
'react-dom': 'ReactDOM' | |
}, | |
output: { | |
dir: 'dist', | |
format: 'umd', | |
sourcemap: true, | |
}, | |
plugins: [ | |
babel({ | |
exclude: 'node_modules/**', | |
presets: [ | |
[ | |
'@babel/preset-env', | |
{ | |
corejs: 3, | |
useBuiltIns: 'usage' | |
} | |
], | |
'@babel/preset-react' | |
] | |
}), | |
resolve({ | |
mainFields: ['browser', 'jsnext', 'module', 'main'] | |
}), | |
commonjs({ | |
sourceMap: true, | |
include: 'node_modules/**' | |
}), | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment