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

[1.0] Preloader script prefixes not acting as intended when sourcemaps are disabled #988

Closed
scottyeck opened this issue May 18, 2017 · 9 comments

Comments

@scottyeck
Copy link
Contributor

scottyeck commented May 18, 2017

Current version: (latest canary at time of writing)
1.0.0-alpha15-alpha.7211d781

When I run gatsby build, the preloader script prefixes do not match up with the scripts in /public - instead, they're just /x where x is just a single character. Top of index.html reads as follows:

<head>
    <link rel="preload" href="/p" as="script" />
    <link rel="preload" href="/p" as="script" />
    <link rel="preload" href="/l" as="script" />
    <link rel="preload" href="/a" as="script" />
    <link rel="preload" href="/c" as="script" />

All the while, the assets output to public read as follows:

app-58579413a27c41b952ee.js
chunk-manifest.json
commons-97a5dea1afd5fc29d501.js
layout-component---index-249467b39ee2266b325d.js
page-component---src-pages-404-jsx-e1d6c2e05b728281adb2.js
page-component---src-pages-about-jsx-ad9f47b75e2e15931b48.js
page-component---src-pages-app-js-1c46b1e6c9cb8804f709.js

(etc.)

Looks like the preloader-link generating mechanism in static-entry.js is just slicing off the first character via the fetchKey that gets passed to _.get.

const fetchKey = `assetsByChunkName[${script}][0]`

This gets resolved when I remove the 0-index at the end of the fetchKey which makes sense. Will PR, though I wanted to make sure that this was outlined. In the event that this is a use-case specific to us, I'd like to know why.

(Edit - forgot to actually include the example output)

scottyeck pushed a commit to fabrictech/gatsby that referenced this issue May 18, 2017
@KyleAMathews
Copy link
Contributor

This doesn't seem right — the "fetchKey" is for pulling info off the stats.json. The [0] is for getting the first value off the array. Perhaps there's something goofy about the stats.json file your build is producing? Looking at the core example sites, they don't have this problem.

@scottyeck
Copy link
Contributor Author

@KyleAMathews Yeah currently returning a string - any thoughts why this might be happening?

@KyleAMathews
Copy link
Contributor

KyleAMathews commented May 18, 2017 via email

@scottyeck
Copy link
Contributor Author

@KyleAMathews Looks like there are a few other funky things going on and they all point back to stats.json - going to run some comparisons against the examples in core like you suggested.

@scottyeck
Copy link
Contributor Author

@KyleAMathews We disable sourcemaps in production. When I enable them, this goes away. Perhaps the check should be conditional?

@scottyeck scottyeck changed the title [1.0] Preloader script prefixes not acting as intended [1.0] Preloader script prefixes not acting as intended when sourcemaps are disabled May 18, 2017
@KyleAMathews
Copy link
Contributor

KyleAMathews commented May 18, 2017 via email

@KyleAMathews
Copy link
Contributor

Haha and just saw your PR doing that :-) will merge and release a bit later.

@scottyeck
Copy link
Contributor Author

@KyleAMathews thanks!

@KyleAMathews
Copy link
Contributor

Merged and published new canary

KyleAMathews pushed a commit that referenced this issue Jun 7, 2017
* Fixes 0-index issue with link preloader as per #988

* Allowing for disabled sourcemaps

* Fix bad logic

* Adds redux example

* Ignores children in prop type validation

* Rolls back to older canary to alleviate 404 issues

* Example title metadata

* Separate createStore

* First pass at wrapping server render body

* Moves api implementation into gatsby-ssr.js

* Updates metadata
scottyeck pushed a commit to fabrictech/gatsby that referenced this issue Jun 28, 2017
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