-
Notifications
You must be signed in to change notification settings - Fork 361
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
Add target environment option #38
Conversation
@@ -13,6 +13,7 @@ prog | |||
.option('--entry, -i', 'Entry module(s)') | |||
.option('--output, -o', 'Directory to place build files into') | |||
.option('--format, -f', 'Only build specified formats', 'es,cjs,umd') | |||
.option('--target', 'Specify your target environment', 'node') |
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 use target
, because that's the name in webpack. However, environment
or platform
may be more descriptive.
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'm good with replicating webpack's naming there.
src/index.js
Outdated
@@ -206,7 +206,8 @@ function createConfig(options, entry, format) { | |||
}), | |||
useNodeResolve && nodeResolve({ | |||
module: true, | |||
jsnext: true | |||
jsnext: true, | |||
browser: options.target === 'browser' |
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.
Can we just avoid the extra option and set browser: true
always? If you're building for node, you'll use --external all
anyway, so this will never be hit.
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'd just do browser: options.target!=='node'
.
When building isomorphic libraries, it's useful to bundle browser versions of dependencies. The
target
option makes this possible and provides flexibility to make environment-based decisions in the future.