stencil icon indicating copy to clipboard operation
stencil copied to clipboard

hashFileNames not working as expected

Open nbgmtin opened this issue 7 years ago • 2 comments

Stencil version:

 @stencil/[email protected]

I'm submitting a:

[x] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior:

First in our stencil.config.js, we have made sure to set hashFileNames: true.

Now looking in the dist folder, there's a my-comp folder ("my-comp" is the name of the component). In that folder there's my-comp.js and my-comp.esm.js. These files should be loaded like this:

<script type="module" src="my-comp.esm.js"></script>
<script nomodule="" src="my-comp.js"></script>

The problem is that these files should be hashed. They are the first files to load on the browser. I tried hashin them myself but then the whole component breaks since other files are specifically looking for my-comp.esm.js.

Expected behavior:

The produced files should look something like this:

<script type="module" src="my-comp-43534.esm.js"></script>
<script nomodule="" src="my-comp-34533.js"></script>

Steps to reproduce:

Build your project with hashFileNames set to true

Related code:

// insert any relevant code here

Other information:

nbgmtin avatar Sep 12 '19 07:09 nbgmtin

I looked at the minified file and noticed it has a fallback to data-namespace="my-comp". So anyone running into the same issue simply add data-namespace="*your-component name*" to your <script> tag. So it looks something like this:

<script type="module" data-namespace="my-comp" src="/Assets/Bundle/Scripts/gdpr-result-page/my-comp.esm.js"></script>
<script nomodule="" src="/Assets/Bundle/Scripts/gdpr-result-page/my-comp.js"></script>

nbgmtin avatar Sep 12 '19 12:09 nbgmtin

Why was this closed? :/

nbgmtin avatar May 07 '20 07:05 nbgmtin