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

ember-auto-import publicAssetURL maybe incompatible with fingerprint prepend #537

Open
smithrp opened this issue Sep 15, 2022 · 1 comment

Comments

@smithrp
Copy link

smithrp commented Sep 15, 2022

Hi there!

I have a situation where I am seeing dual-prepended urls on javascript files when following the instructions in the docs. I'm not positive but it might be related with this issue. I've reproduced the error here to make it easier to see. If you pull down that repo and run ember build --environment=production from the test-app you'll be able to see the problem by searching for .wasm in the dist folder. Locally I see something that looks like this:

e.exports=t.p+"9dea5fdc71a12896aa7c.wasm" // <- this is correct 
e.exports=t.p+"https://foo.bar.com/assets/5aa1c302d0f7aff8ab38-b815187f398d082e9ef9d9e7601c19e1.js" // <- this is incorrect because its already prepended with the fingerprint prepend url

In my case the t.p = "https://foo.bar.com/assets/" which is the publicAssetURL configured in ember-auto-import.

The issue is that the wasm is correctly being linked but the url for the js worker has a dual url on it. If I add wasm to the list of files that are included then it gets the same dual-url on it as well.

Any help you can provide would be greatly appreciated! Thanks in advance!
-Ryan

@ArnaudWeyts
Copy link

Hi! I also just ran into this issue when using a classic Ember app, and assets provided by an ember-addon with ember-auto-import. Embroider apps don't seem to suffer from this issue, and the asset is also only "fingerprinted" once (by webpack).

The way I temporarily fixed it in our classic apps was by excluding the files from our addon for fingerprinting:

// ember-cli-build.js
// ...
  fingerprint: {
    exclude: ['my-addon']
  }
// ...

This setup results in a correct "fingerprinted" asset, but without the double prepended URL.

Addon index.js for reference:

// my-addon/index.js
module.exports = {
  name: require('./package').name,
  options: {
    autoImport: {
      webpack: {
        module: {
          rules: [
            {
              test: /\.png/,
              type: 'asset/resource',
              generator: {
                filename: 'my-addon/images/[name].[hash][ext][query]',
              },
            },
          ],
        },
      },
    },
  },
}

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