You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rspack will make an async entry if meet syntax like
consturl=newURL('./foo.ts',import.meta.url)
So all dependencies in foo.ts can be bundled into single file, and returns the file path in runtime.
Implementation
Currently JavascriptParser already supports parsing syntax like new URL('./foo', import.meta.url), the syntax will become a URLdependency.
The URL dependency will resolve treat ref module as asset module. We can make it a entry block instead, with entryOptions: { chunkLoading: false }, so that it becomes the single file in the last.
URL dependency can be treated as a entry block. When building chunk graph, all entry block generates an async entrypoint chunkGroup.
We disable its chunkLoading and asyncChunks, so that the ref module results in only 1 file at last.
Using with parser.javascript.url
It can work with parser.javascript.url. If parser.javascript.url equals:
false: Rspack won't parse new URL syntax at all.
'relative' and 'new-url-relative' are 2 ways to render the returned value of new URL.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Provide a parser config to bundle URL dependency. For example:
Motivation
Current behavior is to treat
fooas asset module, and do not transform it at all, leaves the.tsfile in output ontouched.It's very helpful if we make it a unique async entry, so that the ref module can be transformed and bundled by Rspack during the same compilation.
Usage
The one possible config is
Rspack will make an async entry if meet syntax like
So all dependencies in
foo.tscan be bundled into single file, and returns the file path in runtime.Implementation
Currently
JavascriptParseralready supports parsing syntax likenew URL('./foo', import.meta.url), the syntax will become a URLdependency.The URL dependency will resolve treat ref module as asset module. We can make it a entry block instead, with
entryOptions: { chunkLoading: false }, so that it becomes the single file in the last.URL dependency can be treated as a entry block. When building chunk graph, all entry block generates an async entrypoint chunkGroup.
We disable its chunkLoading and asyncChunks, so that the ref module results in only 1 file at last.
Using with
parser.javascript.urlIt can work with
parser.javascript.url. Ifparser.javascript.urlequals:new URLsyntax at all.'relative'and'new-url-relative'are 2 ways to render the returned value ofnew URL.Beta Was this translation helpful? Give feedback.
All reactions