Skip to content

Conversation

@kzc
Copy link
Contributor

@kzc kzc commented Sep 12, 2020

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers:

Addresses missing functionality mentioned in #3312.

Description

Presently rollup can only process esm via stdin. This PR adds the ability to specify the CLI stdin file extension via --stdin=ext allowing other inputs such as JSON:

echo '{"foo": 42, "bar": "ok"}' | rollup --stdin=json -p json

A synthetic file name "-.ext" is used internally to represent the stdin filename with an extension in order to work with existing plugins with suffix-based logic. Stdin based input can still be disabled with --no-stdin if required.

Unfortunately this new stdin extension feature will not work with plugins that interrogate the filesystem to read input files such as @rollup/plugin-typescript. For this scenario other plugins like @rollup/plugin-sucrase or rollup-plugin-esbuild could be used instead.

@codecov
Copy link

codecov bot commented Sep 12, 2020

Codecov Report

Merging #3775 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3775   +/-   ##
=======================================
  Coverage   97.03%   97.03%           
=======================================
  Files         185      185           
  Lines        6465     6466    +1     
  Branches     1874     1875    +1     
=======================================
+ Hits         6273     6274    +1     
  Misses        101      101           
  Partials       91       91           
Impacted Files Coverage Δ
cli/run/commandPlugins.ts 97.36% <100.00%> (ø)
cli/run/stdin.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1a6cb46...9133c4d. Read the comment docs.

@kzc
Copy link
Contributor Author

kzc commented Sep 12, 2020

The code coverage failure seems rather insignificant - a partial miss in one line.

@lukastaegert Feel free to take over this PR to change its testing and implementation as you see fit. It works fine my own use. I think others could benefit from this new functionality as well.

@kzc
Copy link
Contributor Author

kzc commented Sep 12, 2020

The code was simplified and coverage now passes.

Copy link
Member

@lukastaegert lukastaegert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good!

@lukastaegert lukastaegert merged commit 916718f into rollup:master Sep 16, 2020
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.

2 participants