Add additional options for emitting lualib bundle #1662
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds two new configuration options, which control how the lualib bundle is saved to disk:
luaLibName: Sets the name to use for the lualib bundle. For example, I find the namelualib_bundleto be vague, so I usually change it totypescriptto make it clear what the library is for.luaLibEmit: Setting this tofalseprevents the lualib bundle from being emitted. This is useful to avoid storing lualib in bundled code when it's available outside the bundle already, or simply to reduce generated file bloat.These options have been useful for my environment, where I have a multitude of common libraries in a store made available system-wide. Being able to change the name allows me to use a more descriptive file name in that store, and being able to suppress its generation means I don't have the duplicated file dangling around in bundles or the build directory.
Neither of these options can be accomplished through plugins. Changing the name in the generated code could be done with
moduleResolution(I haven't tried), but it would not change the generated file's name on disk or in a bundle, and would potentially break other parts of the code. Suppressing emission can't be done for a bundle, since the file is incorporated betweenafterPrintandbeforeEmitwith no chance to intervene.These changes will not affect users who do not use them; all default settings match how they were before.