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

Fingerprint is appended wrong if files have the same name but different extension #63

Open
tschoartschi opened this issue Nov 29, 2017 · 2 comments

Comments

@tschoartschi
Copy link

tschoartschi commented Nov 29, 2017

I first posted this issue in Ember-Cli because I didn't know where to open this issue but after a discussion on Slack I think it better fits here. I just copy and paste it, the original issue is here (ember-cli/ember-cli#7466).

When I build an Ember app with the production flag then the broccoli-asset-rewrite does a wrong rewrite of my assets. In my case this happens when broccoli-asset-rewrite rewrites the path to files which are generated by emscripten.

In my public folder there is another folder which is called assets and there is a folder emscripten. The build result of the emscripten is file called emscripten.js and a emscripten.js.mem file. In the emscripten.js file the path to the .mem file is specified like this: var data = {memoryInitializer: 'assets/emscripten/emscripten.js.mem'};. After fingerprinting the path is rewritten to assets/emscripten/emscripten-e9b1f2eed90901137ae71b1fa2427717.js.mem but the filename is still emscripten.js.mem. When I add the .mem extension to be fingerprinted in ember-cli-build.js then the path is rewritten to assets/emscripten/emscripten-93c4916db6cd46010fdec63ab09a2118.js-2de574db8bcd561db3c5f8221f2abd73.mem but the mem file is named emscripten.js-2de574db8bcd561db3c5f8221f2abd73.mem.

Right now we change the paths by hand, because adjusting the emscripten build is not that easy in our whole workflow. Would be great if there is a solution to this problem. I wanted to create some fix but I ended up at some mad regex in broccoli-asset-rewrite where I can not estimate the impact of a change. Furthermore I'm not sure if the bug really comes from there.

I created a repo which should demonstrate the issue:
https://github.com/tschoartschi/ember-cli-fingerprint-problem
To reproduce ember build -e production and check if the output in emscripten.js in memoryInitializer has the correct path to the mem file. I created two git tags, one with the fingerprinting settings I use and one without any settings. See: https://github.com/tschoartschi/ember-cli-fingerprint-problem/releases

Maybe this issue is related to ember-cli/ember-cli#7149 because there the reporter also has the problems of two hashes in one filename

I also think this issue could be very similar to this one: #57

Maybe also related to: ember-cli/broccoli-asset-rev#94


Output from ember version --verbose && npm --version && yarn --version:

ember-cli: 2.16.2
http_parser: 2.7.0
node: 8.4.0
v8: 6.0.286.52
uv: 1.13.1
zlib: 1.2.11
ares: 1.10.1-DEV
modules: 57
nghttp2: 1.22.0
openssl: 1.0.2l
icu: 59.1
unicode: 9.0
cldr: 31.0.1
tz: 2017b
os: darwin x64
5.4.2
1.1.0
@tschoartschi
Copy link
Author

@rickharrison any update on this issue? Do you need more information or is the issue report fine?

@iqdoq-dfischer
Copy link

Same problem here:

I want to include source map files of an external lib into my production build.
I am including the .js file dynamically in index.html. I do not want to import it with app.import(..).

So in ember-cli-build.js I am including a funnel with file name xyz.js.map.
Fingerprinting is enabled.
After ember build, the source map reference in the xyz.js to the source map file xyz.js.map has been changed to:
xyz-[hashvalue].js-[hashvalue].map

Correct would be in my opinion:
xyz.js-[hashvalue].map

I guess the hash value is appended to every match on the defined fingerprinting file extensions (e.g. ['js', 'map']?
The file extension matching should only match the extension part after the last dot. Today it seems to match every occurrence in the file/url.

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