expose transform and resolveapi from parcel#9193
Conversation
mattcompiles
left a comment
There was a problem hiding this comment.
Couple of questions but this is looking pretty good and love how simple it is to add so far.
@devongovett Would love your thoughts on the comments as well.
| }), | ||
| }); | ||
|
|
||
| let res = await this.#requestTracker.runRequest(request, {force: true}); |
There was a problem hiding this comment.
Should we use force here? My understanding is that force means the cache is ignored.
There was a problem hiding this comment.
I can update that, but it was originally copied from the intiial branch, I will leave this Q to @devongovett on if this is required?
There was a problem hiding this comment.
Just changed it to a configurable value. Follows the config of shouldCacheDisabled from the main config.
I guess this could be helpful to debug transform problems.
| name: 'test', | ||
| }); | ||
|
|
||
| let res = await this.#requestTracker.runRequest(req, {force: true}); |
There was a problem hiding this comment.
Same question here about force.
|
|
||
| let req = createPathRequest({ | ||
| dependency, | ||
| name: 'test', |
There was a problem hiding this comment.
Not sure what the purpose of this name is. Looks like it's normally sourced from the AssetGraphBuilder and it could be Main or Runtimes.
@devongovett Any input on what this should be?
There was a problem hiding this comment.
I changed it to .specifeir
The name seem to be used to construct the req.id only. The first part of id is already hashed, so whatever value here doesn't seem to be matter too much.
Tho, change to specifier should be a lil bit more meaningful.
| filePath: FilePath, | ||
| code?: string, | ||
| env?: EnvironmentOptions, | ||
| pipeline?: ?string, |
There was a problem hiding this comment.
Not sure if pipeline makes sense as a public option? Shouldn't this be inferred from the .parcelrc?
There was a problem hiding this comment.
I am happy to remove this pipline property.
| is_esm_output: asset.env.outputFormat === 'esmodule', | ||
| trace_bailouts: options.logLevel === 'verbose', | ||
| is_swc_helpers: /@swc[/\\]helpers/.test(asset.filePath), | ||
| standalone: asset.query.has('standalone'), |
There was a problem hiding this comment.
Not sure about using a query param to drive this behaviour. Maybe this should be part of the environment?
There was a problem hiding this comment.
I did think about it, for now using query provides some flexibility & less moving part to change the environment. Kinda like a feature flag for jsTransform for now.
| }); | ||
|
|
||
| let res = await this.#requestTracker.runRequest(req, { | ||
| force: shouldDisableCache, |
| }); | ||
|
|
||
| let res = await this.#requestTracker.runRequest(request, { | ||
| force: shouldDisableCache, |
There was a problem hiding this comment.
Turns out I was wrong about this and there's a separate cache layer for transforms so this is safe to hardcode as true.
↪️ Pull Request
Exposes two new API to public use:
So API consumers can use these two features to reuse the same resolve & transform pipelines
during development.
The implementation is mostly a copy of: v2...parcel-node
But it excluded the features specifically for
jestandNodeResolve.And it does not transform
importdirectly torequirethat only specific for node register.As an alternative, we may be able to add another asset query to change it to something else.
eg:
Which provides more customisability, but I am not adding it for now since we still able to post-process the
import()for now.💻 Examples
The new exposed API allows us to do:
And
which allows us to develop custom runtime based on v8 or similar js runtime to share the
transform and resolve pipelines during development without bundling the whole project
which benefits huge projects that takes long time to bundle.
🚨 Test instructions
✔️ PR Todo