rollup/rollup-plugin-json

Avoiding generating many top-level fields

nikhilk opened this issue · 3 comments

I have this in my code:

import packageInfo from '../../package.json';

And this is what gets generated:

const name = "app";
const version = "1.0.0";
...
var packageInfo = {
  name: name,
  version: version,
  ...
};

So a bunch of noise is generated (Eg. dependencies, devDependencies, scripts, etc.)

It would be nice if the following two were enabled.

First: avoiding generating the top-level fields. Instead just this (single object) would be better:

  var packageInfo = {
    name: "app",
    version: "1.0.0",
    ...
  };

Second: providing a way to specify the keys that should be included per included json file. This would allow including just the version field for example.

Why not just use named imports?

import { version } from '../../package.json';

Alternatively, the namedExports: false option will skip the generation of named exports and keep the original concise form.

Hey folks. This is a saved-form message, but rest assured we mean every word. The Rollup team is attempting to clean up the Issues backlog in the hopes that the active and still-needed, still-relevant issues bubble up to the surface. With that, we're closing issues that have been open for an eon or two, and have gone stale like pirate hard-tack without activity.

We really appreciate the folks have taken the time to open and comment on this issue. Please don't confuse this closure with us not caring or dismissing your issue, feature request, discussion, or report. The issue will still be here, just in a closed state. If the issue pertains to a bug, please re-test for the bug on the latest version of Rollup and if present, please tag @shellscape and request a re-open, and we'll be happy to oblige.