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

Add "entrypoints" key to asset manifest #7721

Merged
merged 1 commit into from Sep 24, 2019
Merged

Add "entrypoints" key to asset manifest #7721

merged 1 commit into from Sep 24, 2019

Conversation

samuelmeuli
Copy link
Contributor

@samuelmeuli samuelmeuli commented Sep 23, 2019

Problem:

We would like to generate the index.html file on the server. In order to get code splitting to work, we need to know which chunks are entrypoints of the React app (to be able to request these from the HTML file). Unfortunately, this currently doesn't seem to be possible (see #5225 (comment)).

Ideally, splitChunks.name would simply be set to true in the Webpack config, so the entrypoints could be inferred from the file names. However, this seems to lead to caching issues (see #5030 (comment)).

This PR implements @iansu's suggestion from #5513 (comment): It adds an additional "entrypoints" key to the asset-manifest.json file with the names of the files that need to be included in the generated HTML.

Before:

{
  "files": {
    "main.css": "/static/css/main.2cce8147.chunk.css",
    "main.js": "/static/js/main.fd729682.chunk.js",
    "main.js.map": "/static/js/main.fd729682.chunk.js.map",
    "runtime-main.js": "/static/js/runtime-main.f7c36e2a.js",
    "runtime-main.js.map": "/static/js/runtime-main.f7c36e2a.js.map",
    "static/js/2.ae086021.chunk.js": "/static/js/2.ae086021.chunk.js",
    "static/js/2.ae086021.chunk.js.map": "/static/js/2.ae086021.chunk.js.map",
    "index.html": "/index.html",
    "precache-manifest.be4e4fdd4a55417b6c618c280ec25a62.js": "/precache-manifest.be4e4fdd4a55417b6c618c280ec25a62.js",
    "service-worker.js": "/service-worker.js",
    "static/css/main.2cce8147.chunk.css.map": "/static/css/main.2cce8147.chunk.css.map",
    "static/media/logo.svg": "/static/media/logo.5d5d9eef.svg"
  }
}

After:

{
  "files": {
    "main.css": "/static/css/main.b100e6da.chunk.css",
    "main.js": "/static/js/main.70abf459.chunk.js",
    "main.js.map": "/static/js/main.70abf459.chunk.js.map",
    "runtime-main.js": "/static/js/runtime-main.fdecdd6f.js",
    "runtime-main.js.map": "/static/js/runtime-main.fdecdd6f.js.map",
    "static/js/2.a3ab821d.chunk.js": "/static/js/2.a3ab821d.chunk.js",
    "static/js/2.a3ab821d.chunk.js.map": "/static/js/2.a3ab821d.chunk.js.map",
    "index.html": "/index.html",
    "precache-manifest.47b41692c7614ae757144cfe8f04d3cb.js": "/precache-manifest.47b41692c7614ae757144cfe8f04d3cb.js",
    "service-worker.js": "/service-worker.js",
    "static/css/main.b100e6da.chunk.css.map": "/static/css/main.b100e6da.chunk.css.map",
    "static/media/logo.svg": "/static/media/logo.25bf045c.svg"
  },
  "entrypoints": [
    "static/js/runtime-main.fdecdd6f.js",
    "static/js/2.a3ab821d.chunk.js",
    "static/css/main.b100e6da.chunk.css",
    "static/js/main.70abf459.chunk.js"
  ]
}

Note: This PR is a draft because it requires shellscape/webpack-manifest-plugin#192 to be merged into webpack-manifest-plugin first. Without that change, the information about the order in which the assets need to be included isn't available yet (see #5513 (comment)).

Closes #5513

@iansu
Copy link
Contributor

iansu commented Sep 23, 2019

This is great. Thanks for putting this together. I think we can merge this as soon as the PR in webpack-manifest-plugin is merged.

@iansu iansu added this to the 3.1.3 milestone Sep 23, 2019
@samuelmeuli samuelmeuli marked this pull request as ready for review September 24, 2019 07:14
@samuelmeuli
Copy link
Contributor Author

The author has already merged it. I've updated the required package version.

@iansu iansu merged commit 93150c5 into facebook:master Sep 24, 2019
@iansu
Copy link
Contributor

iansu commented Sep 24, 2019

Thanks!

@samuelmeuli samuelmeuli deleted the asset-manifest-entrypoints branch September 24, 2019 17:26
@lock lock bot locked and limited conversation to collaborators Sep 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

asset-manifest.json generated by CRA2 is not useful
3 participants