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

chore(build): add distribution files #186

Merged
merged 2 commits into from
Nov 27, 2017

Conversation

MediumRareByte
Copy link
Contributor

Added distribution bundle.
#142

Copy link
Collaborator

@alexreardon alexreardon left a 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 to package.json#files
  • add dist to .gitignore
  • remove the dist directory from this commit

@alexreardon
Copy link
Collaborator

Does this naming convention satisfy the Clojurescript requirements? @Frozenlock?

@Frozenlock
Copy link

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.

@alexreardon
Copy link
Collaborator

I think we also need to ensure that we are bundling react

@alexreardon
Copy link
Collaborator

alexreardon commented Nov 20, 2017

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

@Frozenlock
Copy link

Frozenlock commented Nov 21, 2017

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.).
This means that if they are in the externals section of the webpack.config.js (or equivalent), we can avoid duplication.

However, I don't know enough about the vanilla JS ecosystem nor do I want to burden this project.
I would simply ask that you do distribution files as you normally would; we'll handle it from there.

@MediumRareByte
Copy link
Contributor Author

MediumRareByte commented Nov 21, 2017

  • Swap out Webpack for Rollout
  • add dist to package.json#files
  • add dist to .gitignore
  • remove the dist directory from this commit

This is my first time using Rollup, I followed the implementation mentioned in #81

@alexreardon
Copy link
Collaborator

This is looking good. @treshugart does it look good to you?

@Frozenlock would this satisfy your requirements?

@MediumRareByte
Copy link
Contributor Author

Thank you @alexreardon. Please let me know if that suits your bill, @treshugart @Frozenlock :)

"files": [
"/lib"
],
"files": ["/lib", "/dist"],
Copy link

@treshugart treshugart Nov 21, 2017

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).

@treshugart
Copy link

treshugart commented Nov 21, 2017

LGTM but left a comment that we might think about adding now. Some things I'd suggest thinking about for the future:

  • dist/ is really umd/ and can map to browser (I've commented about mapping the current dist/ to that)
  • lib/ is really node/ and can map to main
  • es/ (or even esm/ now that I think about it) that exports es5 (or lowest common denominator) + esm and can map to module
  • Having an esnext/ build for consuming the latest spec is something people are doing more and more. I've done this in Skate and map it to the esnext field.

@alexreardon
Copy link
Collaborator

@treshugart can we implement your suggestions in a follow up issue? It seems like the currently PR solves the immediate need

@treshugart
Copy link

Some things I'd suggest thinking about for the future:

@treshugart
Copy link

treshugart commented Nov 22, 2017

Or if you mean the browser field, that's up to if you think people might be reaching into the dist manually and if you want to consider a folder rename a breaking change. I don't care what you do here.

Copy link
Collaborator

@alexreardon alexreardon left a 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:

rollup.config.js Outdated
name: 'ReactBeautifulDnd',
plugins: [
resolve({
browser: true,
Copy link
Collaborator

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,
Copy link
Collaborator

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({
Copy link
Collaborator

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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?

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.

@alexreardon
Copy link
Collaborator

This is looking good! I will give it a look over next week.

@MediumRareByte
Copy link
Contributor Author

Thanks @alexreardon

rollup.config.js Outdated
import pkg from './package.json';

const args = yargs.argv;
const external = Object.keys(pkg.dependencies || {}).concat(
Copy link
Collaborator

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

@alexreardon
Copy link
Collaborator

Thanks for preserving with this @vinifala

@MediumRareByte
Copy link
Contributor Author

Thanks @alexreardon, React added as only external dependency with proper global mapping :)

@MediumRareByte
Copy link
Contributor Author

MediumRareByte commented Nov 26, 2017

From Tavis CI: oci runtime error: exec failed: container_linux.go:265: starting container process caused "could not create session key: disk quota exceeded"
https://travis-ci.org/atlassian/react-beautiful-dnd/builds/307622143?utm_source=github_status&utm_medium=notification
Looks like we ran out of space.

@alexreardon
Copy link
Collaborator

Oh wow! I am not too worried about that at this stage

@alexreardon
Copy link
Collaborator

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 🎉

@alexreardon alexreardon merged commit b61813d into atlassian:master Nov 27, 2017
@MediumRareByte
Copy link
Contributor Author

Thanks for your patience, @alexreardon. I'm looking forward to contribute further.

@MediumRareByte MediumRareByte deleted the add-dist-files branch November 27, 2017 02:16
@alexreardon alexreardon mentioned this pull request Nov 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants