Skip to content

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

Description

@KevinCarnaille2

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 :)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions