Skip to content

CLI: Return code and CSS modules as JSON when output file is not given#192

Merged
devongovett merged 1 commit intoparcel-bundler:masterfrom
joelmoss:cli_css_modules_out_as_json
Jun 11, 2022
Merged

CLI: Return code and CSS modules as JSON when output file is not given#192
devongovett merged 1 commit intoparcel-bundler:masterfrom
joelmoss:cli_css_modules_out_as_json

Conversation

@joelmoss
Copy link
Contributor

@joelmoss joelmoss commented Jun 1, 2022

My very first rust experience, so be gentle ;)

I wanted a way to get both the resulting code and the CSS modules from the CLI without having to specify an output file, which means I would have to read files to get what I want.

So in this PR, if output-file flag is not given, and css-modules flag is given, the CLI will return a JSON string containing the code and the CSS modules...

{
  "code": ".cLD2Uq_header {\n  background-color: #00f;\n}\n",
  "modules": {
    "header": { "composes": [], "isReferenced": false, "name": "cLD2Uq_header" }
  }
}

All other functionality is maintained.

Would appreciate any feedback. thx

Copy link
Member

@devongovett devongovett left a comment

Choose a reason for hiding this comment

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

Technically, this is a breaking change but I think we can get away with it.

@devongovett
Copy link
Member

We should probably update the tests for this.

@devongovett devongovett merged commit bad5803 into parcel-bundler:master Jun 11, 2022
@devongovett
Copy link
Member

FYI added tests for this and your other PR in a5fdcc1. Also renamed "module" to "exports" in the output JSON to match the JS API.

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