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

Missing docs for data-stencil-namespace script attribute #777

Open
KevinCarnaille2 opened this issue Oct 1, 2021 · 0 comments
Open

Missing docs for data-stencil-namespace script attribute #777

KevinCarnaille2 opened this issue Oct 1, 2021 · 0 comments

Comments

@KevinCarnaille2
Copy link

Stencil version:
@stencil/core@^2.8.0

Description

Hello team,

I think it could be handy to add some documentation about this specific part of generated bundle (the bundle is my-namespace.esm.js, www output):

    // @ts-ignore
    const scriptElm = BUILD.scriptDataOpts || BUILD.safari10 || BUILD.dynamicImportShim
        ? Array.from(doc.querySelectorAll('script')).find((s) => new RegExp(`\/${NAMESPACE}(\\.esm)?\\.js($|\\?|#)`).test(s.src) ||
            s.getAttribute('data-stencil-namespace') === NAMESPACE)
        : null;

Adding data-stencil-namespace="my-namespace" is a really useful fallback, if for example we need to use a bundle with a hash into it, or simply with a different namespace for example :

<script src="/www/build/my-namespace-ej6jau8hu4.esm.js" />

In this specific case, the RegExp is not matching, but using the above HTML attribute fix the issue (scriptElm is not defined if we load some polyfills).

I'm not sure it can be considered as an actual @stencil/core issue or a documentation one, so sorry if it's not relevant here, but I guess it's easier to add some doc for this, than fixing the RegExp itself for the moment :)

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

No branches or pull requests

2 participants