-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Include new URL("...", import.meta.url)
references in the import graph.
#2470
base: main
Are you sure you want to change the base?
Conversation
7a9ff50
to
5e841dc
Compare
I've added a test that covers the most important behaviour. Hopefully I've added it in the appropriate place! |
@evanw Anything I can do to help move this forward? This implementation matches what I believe you support as the best approach: #312 (comment) |
I'm planning on releasing a form of this sometime soon. You can see my work in progress version here: #2508. This will initially require code splitting to be enabled (as well as bundling and ESM output of course) as esbuild's internals currently mean each input module only shows up in one output file. It will also require paths to be explicitly relative (i.e. start with
This doesn't seem like something that should be done because |
Ooooh, thanks, I'm really glad to hear it! 😍
That sounds pretty good to me! Does this also meant that
That seems fair. I don't personally need this, but I do know some others will need this use case. I think it could usually be handled by a relative import of a simple file that wraps the module import. |
Okay, I was able to test by running a production build instead of watch mode. |
`make js-api-tests` fails to include the worker file in the build. This is an adaptation of evanw#2470 , for evanw#2866
`make js-api-tests` fails to include the worker file in the build. This is an adaptation of evanw#2470 , for evanw#2866
There are important use cases when it is valuable to get the bundled URL of a file, such as for web worker instantiation: #312
This PR allows
esbuild
to handle the most portable way to instantiate a module web worker (which works natively in browsers/node
, and is understood by a lot of other bundlers already):This PR implements support by recording such relative URLs in the import graph during AST parsing, thanks in part to @firien here. However, it still has issues:
.ts
and.js
suffixes so I can test it. But:@some/package/worker
if@some/package
exports./worker
..tsx
and.jsx
) should be included by default, possibly any file types as long as the file exists at the referenced relative path (to fully address URL assets bundling #795).import.meta.url
, it should probably be disabled (or even error) for CJS output.new URL
as opposed to looking for URL constructors in other ways?@evanw Could I ask if you think the approach in this PR will work, and the best way to address the issues listed above?