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

Handle fingerprinted asset maps #262

Merged
merged 2 commits into from
Oct 13, 2016

Conversation

arjansingh
Copy link
Contributor

broccoli-asset-rev has the option to fingerprint your asset map file.

This PR adds support for that scenario.

I'm not happy about using the wild card, but I don't think a RegExp will work there.

@arjansingh arjansingh changed the title Assetmap Handle fingerprinted asset maps Sep 10, 2016
@@ -104,7 +104,9 @@ FastBootConfig.prototype.readAssetManifest = function() {
var assetMap = JSON.parse(fs.readFileSync(assetMapPath));
return assetMap;
} catch (e) {
// No asset map was found, proceed as usual
if (assetMapPath) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should at least warn about this when you have an asset map.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning should only show if the assets are fingerprinted and there is not asset map, right? That would be a bad state. If they aren't fingerprinted, then they would be at their expected paths, and the asset map isn't required (As least that's my understanding)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that. Any time getting an assetMap load fails we should log it. If it's a malformed assetMap that fails parse or if it's just absent, the user would benefit from knowing that. We can print the error too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it may be beneficial to include the error message and also state that it's warning, rather than an error in the case that it's not required (non-fingerprinted assets)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, you should only emit warnings if they are actionable. In this case, it will always emit a warning in development mode that you can't get rid of, because asset rewriting is not turned on in development mode. That would drive me crazy, and it will make people less likely to see other, real warnings that we might emit in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other words, I'm in favor of emitting a warning or error if we can't parse the file, or if we would expect the file to exist and it doesn't, but I am not in favor of logging a warning always in development mode if fingerprinting is turned off (which it is by default).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warning (especially after taking care of @danmcclain's feedback) will only trigger if asset map generation is enabled and no asset map was found. I think that is absolutely a scenario that warrants a warning.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the discussion at this week's meeting:

This warning should only be emitted if assetRev && assetRev.options && assetRev.options.enabled.

Copy link
Contributor Author

@arjansingh arjansingh Sep 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomdale changes made in edcd3af

@arjansingh arjansingh force-pushed the assetmap branch 2 times, most recently from cfa1558 to 84bcf6a Compare September 13, 2016 01:30
var assetMapPath = path.join(this.inputPaths[0], 'fastbootAssetMap.json');

try {
var assetMap = JSON.parse(fs.readFileSync(assetMapPath));
return assetMap;
} catch (e) {
// No asset map was found, proceed as usual
if (assetMapPath) {
ui.writeLine(fmt("FastBoot Build: No asset map was found at: %s", assetMapPath), ui.WARNING);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danmcclain switched to using this.ui as well.

@arjansingh
Copy link
Contributor Author

Good to merge?

@briangonzalez
Copy link

Any luck reviewing @danmcclain @tomdale?

@arjansingh arjansingh force-pushed the assetmap branch 2 times, most recently from 3be6fa5 to edcd3af Compare September 22, 2016 22:05
@@ -98,13 +98,16 @@ FastBootConfig.prototype.buildDependencies = function() {
};

FastBootConfig.prototype.readAssetManifest = function() {
if (!this.assetMapEnabled) return '';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we know this before the try/catch block I decided to leverage it to do an early exit. Let me know if you'd rather I didn't.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind this comment.

@danmcclain danmcclain merged commit 358392c into ember-fastboot:master Oct 13, 2016
xg-wang pushed a commit to xg-wang/ember-cli-fastboot that referenced this pull request Nov 16, 2020
…ox-after-request

Build new sandbox after request is done
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

Successfully merging this pull request may close these issues.

4 participants