-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
chore(build): add distribution files #186
Conversation
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.
This is a simple way of building a dist - i like it! However, can we please not add the generated file to the repo itself? Ideally it would just be generated for npm (just as lib
is)
Based on this understanding here are the outstanding tasks:
- add
dist
topackage.json#files
- add
dist
to.gitignore
- remove the dist directory from this commit
Does this naming convention satisfy the Clojurescript requirements? @Frozenlock? |
Thank you for doing this. IIRC as long as one can easily generate a minified file for distribution we can package it with a minimum of manual operations. I'll try to look at this in more details this evening and come back with an answer. |
I think we also need to ensure that we are bundling react |
Also, there is a lot of webpack stuff in there that we could avoid if we used rollup. It seems fairly easy to setup also - and we could use /lib/index.js as the entry point. It also seems to have simple options for peer dependencies |
After reviewing the process, the thing we need is the browserified files (like those). We provide our own packaged dependencies for the most popular libraries (React, react-motion, etc.). However, I don't know enough about the vanilla JS ecosystem nor do I want to burden this project. |
46ebc7b
to
eff5f8a
Compare
This is my first time using Rollup, I followed the implementation mentioned in #81 |
This is looking good. @treshugart does it look good to you? @Frozenlock would this satisfy your requirements? |
Thank you @alexreardon. Please let me know if that suits your bill, @treshugart @Frozenlock :) |
"files": [ | ||
"/lib" | ||
], | ||
"files": ["/lib", "/dist"], |
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.
Would be good to also add a browser
field next to main
that maps to dist/index.js
(it will be minified by bundlers, however unpkg won't serve the min file).
LGTM but left a comment that we might think about adding now. Some things I'd suggest thinking about for the future:
|
@treshugart can we implement your suggestions in a follow up issue? It seems like the currently PR solves the immediate need |
|
Or if you mean the |
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.
I had a look and it looks as though react is still being included in the generated files.
A few things I think should still be done:
- Add React as an external: https://rollupjs.org/#peer-dependencies
- Add the babel plugin and exclude node modules from needing to be transpiled
- Add
build:dist
tobuild
command
rollup.config.js
Outdated
name: 'ReactBeautifulDnd', | ||
plugins: [ | ||
resolve({ | ||
browser: true, |
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.
why is this needed?
// some package.json files have a `browser` field which
// specifies alternative files to load for people bundling
// for the browser. If that's you, use this option, otherwise
// pkg.browser will be ignored
browser: true, // Default: false
rollup.config.js
Outdated
name: 'ReactBeautifulDnd', | ||
plugins: [ | ||
resolve({ | ||
browser: true, |
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.
it looks like this already defaults to true
// use "main" field or index.js, even if it's not an ES6 module
// (needs to be converted from CommonJS to ES6
// – see https://github.com/rollup/rollup-plugin-commonjs
main: true, // Default: true
rollup.config.js
Outdated
browser: true, | ||
main: true, | ||
}), | ||
commonjs({ |
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.
not sure what this one is for. I think just listing react as an external is enough
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.
rollup-plugin-commonjs
complains that React does not export 'Component', 'Children', 'createElement'
as named exports. This was the solution I've found.
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.
Listing React as an external dependency leads to
(!) Missing global variable name Use options.globals to specify browser global variable names corresponding to external modules react (guessing '_react')
I'm not sure if that's fine, or should I include globals: { react: 'React' }
to rollup.config.js
?
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.
Yeah, I think you're going to have to do that. I've found you can automate the dependencies part by doing something like:
const pkg = require('./package.json');
const skip = {
...pkg.dependencies,
...pkg.devDependencies,
...pkg.optionalDependencies,
...pkg.peerDependencies
};
Jason Miller (of Preact fame) also shows this here.
86338c6
to
f7f70d3
Compare
This is looking good! I will give it a look over next week. |
Thanks @alexreardon |
rollup.config.js
Outdated
import pkg from './package.json'; | ||
|
||
const args = yargs.argv; | ||
const external = Object.keys(pkg.dependencies || {}).concat( |
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.
Getting close! I think this should only include react
. The other dependencies are internal and should not need to be provided by consumers.
Also, I am getting this warning:
(!) Missing global variable names
Use options.globals to specify browser global variable names corresponding to external modules
react (guessing '_react')
I would expect that this should be listed as 'React' in the options.globals
Thanks for preserving with this @vinifala |
f7f70d3
to
f567a85
Compare
Thanks @alexreardon, React added as only external dependency with proper global mapping :) |
From Tavis CI: |
Oh wow! I am not too worried about that at this stage |
Well done @vinifala !! I had a look locally and it is looking good. I'll merge this pr and it will go out in the next release. Thanks for your ongoing efforts to get this across the line 🎉 |
Thanks for your patience, @alexreardon. I'm looking forward to contribute further. |
Added distribution bundle.
#142