Allow transform-runtime to insert runtime references with absolute paths. #8435
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 allows users to run
transform-runtimebroadly across a whole project. By default,transform-runtimeimports from@babel/runtime/foodirectly, but that only works if@babel/runtimeis in the node modules of the file that is being compiled. This can be problematic for nested node modules, or npm-linked modules, among other cases. To avoid worrying about how the runtime module's location, this allows users to resolve the runtime once up front, and then insert absolute paths to the runtime into the output code.Using absolute paths is not desirable if files are compiled for use at a later time, but in contexts where a file is compiled and then immediately consumed, they can be quite helpful.
This PR exposes two approaches for resolving the runtime:
absoluteRuntime: true- Resolve the runtime:cwdif thetransform-runtimeplugin is passed as a programmatic arg to Babeltransform-runtimeis enabled via a config fileabsoluteRuntime: '/projects/thing/src'__dirnameof some general build process script. e.g. will look at/projects/thing/src/node_modules/@babel/runtime/foo/projects/thing/node_modules/@babel/runtime/foo/projects/node_modules/@babel/runtime/foo/node_modules/@babel/runtime/foocc @insin