Closed dominicbarnes closed 9 years ago
I'm going to work on adding more tests for the CLI, so hold off on merging this quite yet. But feel free to discuss and suggest changes right now.
/cc @stephenmathieson @MatthewMueller @yields
Yay, the tests are failing for node 0.10 (only examples it looks like)
I'll have to look into this later tonight.
imo, --development
should still imply source maps
This is awesome @dominicbarnes! I left a few comments, but overall this lgtm!
IMHO atomic options are better.
As the description already says: --development
just implies include development dependencies
Then, if you want development dependencies and sourcemaps you can still:
duo --development --source-maps entry.js
I believe the more verbose the options are the better.
I'm with @cristiandouce on this one, I prefer the more explicit options. (was wanting to revisit duo-pack itself to change that API to reflect this)
@dominicbarnes @cristiandouce is there ever a time when you'd want dev deps installed but not want source maps included?
@stephenmathieson maybe for testing in a CI? dev deps are installed when running assert and stuff, right?
@cristiandouce would you actually actually build a file for testing in a ci differently than in your browser?
this seems silly to me:
test-browser: build/test.js
duo test --build $< browser
test-ci: build/ci.js
duo test --build $< phantomjs
build/test.js: test.js index.js
duo --development --source-maps index.js > $@
build/ci.js: test.js index.js
duo --development > $@
nice!
though --development
should implicitly add source-maps i think, maybe --source-map
should override the inline source-map if needed.
Sounds like we have a bit of a tie going on here, would you like to weigh in @MatthewMueller? (ie: should --development
automatically imply --source-map
?)
And just to make sure everyone understands the exact semantics of what I've proposed here:
# generates build/index.js + build/index.js.map
duo --source-map index.js
# generates build/index.js + inline source-map
duo --inline-source-map index.js
# generates build/index.js (no source-maps)
duo index.js
I look around at a couple other libraries to see how they did this:
--source-map
flag (plus several other source-map related flags)--map
option. (no other config)--debug
flag, no other config) They defer to another library (exorcist) to generate external source-maps.--source-maps-inline
) and external source-maps (via --source-maps
)Looks like I adopted the same methodology as babel. (w/o even realizing it!)
i agree with most of those changes, but i can't understand why the need for --inline-source-map
?
seems like it would be nicer from a user point-of-view to have inlined source maps whenever --development
is given, but also have --source-map
to override the inlined ones...
i might be missing something
@yields i agree fully
@yields the main reason for the extra CLI flag was because having an optional value for a flag is tricky. At first I wanted to do --source-maps [inline]
, which meant I wanted either duo --source-maps index.js
or duo --source-maps inline index.js
. Unfortunately, commander would confuse index.js
for the that optional bit.
So, @yields and @stephenmathieson would like something like this:
# generates build/index.js + build/index.js.map
duo --source-map index.js
duo --development --source-map index.js
# generates build/index.js + inline source-map
duo --development index.js
# generates build/index.js (no source-maps)
duo index.js
I think I still prefer the more explicit options, but I can live with either! :)
Oh btw, I've made a slight change. I've renamed the flags to be plural (since multiple entries can be processed at once)
I just had a compromise/idea, what if we support both --development
and --inline-source-maps
?
# generates build/index.js + build/index.js.map
duo --source-maps index.js
duo --development --source-maps index.js
# generates build/index.js + inline source-map
duo --development index.js
duo --inline-source-maps index.js
# generates build/index.js (no source-maps)
duo index.js
This also opens up the possibility for turning off source-maps. (assuming you had a reason)
# only downloads dev deps, no source-maps
duo --development --no-inline-source-maps index.js
/cc @yields @stephenmathieson
@stephenmathieson what I mean is that I'd avoide sourcemaps or inline sourcemaps when building build/test.js
. Yet, nevermind, It's not a big issue to me.
I'd just prefer to avoid the "implies" which rely hidden on documentation which you only check when the command fails.
If the option --development
implies sourcemaps, It'd good to add the implication at it's command line description, so when duo --help
I see exactly what the development flag does.
This seems silly to me:
# only downloads dev deps, no source-maps
duo --development --no-inline-source-maps index.js
having to exclude some hidden default. It's more explicit to add flags that add functionality than remove. IMHO
Hey guys, it's been almost a week and I haven't heard anything new. Since we seem to be divided, would you guys be willing to merge this as-is, and we can change it later if it turns out to be a problem?
I'd really like to hear from @MatthewMueller regarding the discussions above, but I will probably proceed with merging this sometime this weekend if I don't hear anything else.
Didn't mean to leave this hanging @dominicbarnes! I'm tentatively with @yields in that --development
should imply source-maps and we should make smart choices for the developer about the options of --development
.
That being said, I'm not familiar with all the pros and cons of external vs internal source maps, but I think we should take a stand on how development "should" be. in other words, we should be weighing the pros and cons and making that decision so newcomers don't have to. I think what you suggested @dominicbarnes in your "compromise/idea" would work.
@duojs/owners I'm going to try and wrap this up today, here's what the final API should look like:
# generates build/index.js + build/index.js.map
duo --external-source-maps index.js
duo --development --external-source-maps index.js
# generates build/index.js + inline source-map
duo --development index.js
# generates build/index.js (no source-maps)
duo index.js
This preserves the current behavior of --development
(that implies inline source maps) while allowing for external source-maps with an extra flag. Success!
This adds support for external source-maps!
The
--development
flag no longer implies source-maps, instead the--source-maps
(or--inline-source-maps
) flags must be used.Duo#sourceMap(value)
has been added to the API.value === true
, an external source-map will be created. (ex:build/index.js
build/index.js.map
)value === 'inline'
, the output file will have the sourcemap added as an inline comment.value === false
, no source-maps will be generated at all.In the CLI, when printing to
stdout
, only inline source-maps are supported. Thus, if you only specifytrue
, it will automatically change toinline
.BREAKING: this changes the api for
Duo#run()
, it now returns the same object thatduo-pack@2
returns. (ie:{ code, map }
)