rspack
rspack copied to clipboard
[Feature Request]: Dynamic entry
What problem does this feature solve?
We plan to migrate from webpack. The existing function is to implement access-time building through dynamic entry (that is, the build task is triggered when the user accesses the local URL). The entry configuration code is as follows:
// The file record entry changes
const entryDynamicFile = `${process.env.BUILD_ENTRY_DYNAMIC}-${type}.json`
const ENTRY_DYNAMIC = 'entry-dynamic'
module.exports = {
entry: () => {
// Return object include all entries key value
const entries = getEntry()
const list = JSON.parse(readFileSync(entryDynamicFile))
const dynamicEntries = {}
list.forEach((name) => { dynamicEntries[name] = path.join(process.cwd(), entries[name]) })
dynamicEntries[ENTRY_DYNAMIC] = entryDynamicFile
return dynamicEntries
}
}
We find the corresponding entry based on the URL visited by the user. If the current entry history has not been constructed, a loading page will be returned. We use this feature to dynamically change the entry. When the construction is completed, refresh the entry page again to display the true content of the entry.
What does the proposed API of configuration look like?
The Webpack Document: https://webpack.js.org/configuration/entry-context/#dynamic-entry
By now, you can try to export a function type option as a workaround.
By now, you can try to export a function type option as a workaround.
I don’t understand. Currently rspack does not support function type entries. Can you provide a simple code example?
Maybe @h-a-n-a means, you can export function type rspack config https://www.rspack.dev/config.html#exporting-a-configuration-function
Maybe @h-a-n-a means, you can export function type rspack config https://www.rspack.dev/config.html#exporting-a-configuration-function
That's exactly that I mean. Sorry for making it confusing.
This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!
bump
https://github.com/childrentime/rspack-EntryOptionPlugin-diff-with-webpack
I am using the EntryOptionPlugin to add a route when a page route is accessed. However, I found that rspack's EntryOptionPlugin does not allow a function to be used as an entry. This is clearly inconsistent with the plugins in webpack.
https://github.com/webpack/webpack/blob/4b4ca3bb53f36a5b8fc6bc1bd976ed7af161bd80/lib/EntryOptionPlugin.js#L31-L35
https://github.com/web-infra-dev/rspack/blob/main/packages/rspack/src/lib/EntryOptionPlugin.ts#L28-L31 Just saw that it's not supported yet. 😭
Close with https://github.com/web-infra-dev/rspack/pull/6393