Skip to content
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

Attempts to load multiple modules only loads the first. #12

Open
caschbre opened this issue Mar 3, 2020 · 2 comments
Open

Attempts to load multiple modules only loads the first. #12

caschbre opened this issue Mar 3, 2020 · 2 comments

Comments

@caschbre
Copy link

caschbre commented Mar 3, 2020

I'm attempting to load several modules (multiple bundle.js files in different directories) using the following method:

<script type="module" src="https://unpkg.com/dimport?module" data-main="/distinct/path/bundle.js"></script>
<script nomodule defer src="https://unpkg.com/dimport/nomodule" data-main="/distinct/path/bundle.js"></script>

The first bundle.js gets loaded, however the subsequent bundle.js files never load.

<script type="module" src="https://unpkg.com/dimport?module" data-main="/first/bundle.js"></script>
<script nomodule defer src="https://unpkg.com/dimport/nomodule" data-main="/first/bundle.js"></script>

<script type="module" src="https://unpkg.com/dimport?module" data-main="/second/bundle.js"></script>
<script nomodule defer src="https://unpkg.com/dimport/nomodule" data-main="/second/bundle.js"></script>

In the above example, only /first/bundle.js gets loaded.

Is what I'm attempting to do even feasible?

@lukeed
Copy link
Owner

lukeed commented Mar 3, 2020

Hey,

I'm pretty sure dimport gets downloaded once (because CDN cache & how ESM imports natively work) and so there's only 1 instance of dimport that can be "self-aware" and fetch its own attribute.

Can you try appending unique query strings to each script? unpkg.com/dimport?module&123

I am on my phone right now, so I can't tell if that affects the caching headers from unpkg

@caschbre
Copy link
Author

caschbre commented Mar 3, 2020

Unfortunately the unique query string approach did not work. Any other thoughts?

Can a comma delimited list of modules be added to data-main or is that only expecting a single path?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants