question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature - Export the manifest object from runtime chunk

See original GitHub issue

Feature request

What is the expected behavior? If the project generates a single runtime chunk file by option optimization: { runtimeChunk: 'single' } Pls expose the manifest content in that runtime chunk, I believe there is a function call jsonpScriptSrc contain such content, if u pass chunkId in, u will get the public path of that chunk as return value:

image

What is motivation or use case for adding/changing the behavior? I’m developing a plugin(webpack-prefetcher) to help people do better prefetch/preload in webpack

This plugin requires a manifest file to be downloaded before it can prefetch/preload anything, now I can get the manifest file by the WebpackManifestPlugin

But if runtime chunk already has manifest data, the use of this manifest plugin is quite unnecessary in my opinion.

How should this be implemented in your opinion? Modify the runtime chunk file’s template, expose the jsonpScriptSrc function.

Are you willing to work on this yourself? yes! but need some guidance…

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
xiaogdgenuinecommented, Feb 12, 2020

@evilebottnawi I understand, and I found a way around this without changing the source code of webpack 4.

I wrote a webpack plugin to tap mainTemplate.hooks.localVars hook in the lower priority to achieve this:

compilation.mainTemplate.hooks.localVars.tap({
        name: pluginName,
        // lower priority compare to `JsonpMainTemplatePlugin`
        stage: 1,
      }, (source, chunk, hash) => {
        let newSource = source;

        // Expose get js path function
        newSource = newSource.replace(
                                   "function jsonpScriptSrc", 
                                   "window.jsonpScriptSrc = function jsonpScriptSrc");

        return newSource;
})

Really hacky but it works perfect for me. 😛

0reactions
webpack-botcommented, May 29, 2020

Issue was closed because of inactivity.

If you think this is still a valid issue, please file a new issue with additional information.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Manifest - webpack
A webpack runtime and manifest that conducts the interaction of all modules. ... even split into smaller chunks for lazy-loading by webpack's optimization...
Read more >
Micro Frontend Architecture: Import chunks from another ...
This article describes how I wrote a Webpack plugin that imports chunks from other Webpack bundles at runtime. It is part of a...
Read more >
The Single Runtime Chunk > Webpack Encore - SymfonyCasts
When two different files import the same module, they do get the exact same object in memory. However, by default, Webpack treats different...
Read more >
decreasing front-end size and improving caching - Ivan Akulov
runtime – when webpack's runtime code changes (i.e. rarely and only with new webpack versions),; manifest.json – when you add a new chunk...
Read more >
Typescript ReferenceError: exports is not defined
js file that tsc generated. You will find this at the very top: Object.defineProperty(exports, "__esModule", { ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found