Skip to content
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

Inline inject that supports sideEffects metadata #1169

Open
ggoodman opened this issue Apr 19, 2021 · 0 comments
Open

Inline inject that supports sideEffects metadata #1169

ggoodman opened this issue Apr 19, 2021 · 0 comments

Comments

@ggoodman
Copy link

The current inject feature is very powerful but requires files to be available on disk to leverage.

I would like to suggest the option of supporting an alternative inject specifier format that allows the contents of the injected file to be specified inline. In order to also be able to benefit from the tree-shaking applicable to side-effect-free modules, it would also be helpful to be able to specify this metadata inline.

Illustration of the general idea:

await build({
  // ...
  inject: [
    {
      content: 'export const foo = "bar";',
      // optional, for debug and error info
      fileName: 'inject-bar-foos.js',
      // optional, for determining if it can be safely pruned when no exported symbols are referenced
      sideEffects: false,
    },
  ],
  // ...
});
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

No branches or pull requests

1 participant