-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Using public URL for dynamic imports #4747
Comments
I think you are using Parcel 1 but referring to the sources for Parcel 2. Could you share more details about your environment? |
You are correct I am using Parcel 1 ... the correct file should have been https://github.com/parcel-bundler/parcel/blob/1.x/src/builtins/bundle-url.js ... I just did a search on Github for the code and didn't see the version number. I don't know too much about the environment but basically the React application that parcel is bundling up is hosted within AWS and is then embedded into Abobe Experience Manager. Everything works fine until the application is embedded in the CMS where the include of the first lazy loaded js file will break as the base url is incorrect. The include is basically picking up the base url of the CMS as the React app is included via JavaScript. So the error thrown in getBundleUrl when using debugger is:
So base url ends up being https://example.com/etc/cms/ rather than https://example.com/parcel-dist |
@mischnic Did you have any thoughts on how we might resolve this issue? I'm happy to do some development work. Looks like this issue will also be present in Parcel 2. Would be great if there was a way to not have to fork the repo. Also having trouble working out best way to get the public url into each generated file at time bundle is created. |
So the main bundle is loaded as For Parcel 2, all of this bundle loading is implemented in the js runtime plugin: parcel/packages/runtimes/js/src/JSRuntime.js Line 340 in d19bee1
So in the worst case, you could use your own runtime plugin instead of the default one (without "forking" Parcel itself) |
example.com/etc/cms/assets.js is a script that is tasked with embedding the html output from Parcel which then loads the bundled js etc but with the wrong path. Its part of how SPAs are embedded into this particular CMS I believe. Thank you for the information regarding Parcel 2 that looks like it could make things much easier, as you say without forking. Is there any rough schedule of how long V2 will be in beta? Thanks again for your help and for the information regarding Parcel 2 runtime plugins. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. |
💬 RFC
When using code splitting and thus dynamic imports allow for public URL to be specified rather than trying to determine base URL based on stacktrace
🔦 Context
I am currently trying to get a React application working on some complex infrastructure which is out of my control. Due to the way this works the URL matched it the Error.stack is not correct ... referenced here #2434 which is basically this code https://github.com/parcel-bundler/parcel/blob/v2/packages/runtimes/js/src/bundle-url.js#L23 (Not sure if that is the right file as function is defined multiple places)
I would like to be able to use the public url which is already being passed into the parcel command in our case.
💻 Examples
Possible solution
parcel src/app.html -d dist/output/ --cache-dir .cache/output/ --public-url https://example.com/dist_alias --use-public-url-for-import true
And then check for this flag before trying to match the base url from error trace.
But am really open to anything that will allow for us to get the application working on this infrastructure.
The text was updated successfully, but these errors were encountered: