-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Adds a runtime variable __webpack_require__.dp to generate a dynamic path #19238
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
Open
arkapratimc
wants to merge
13
commits into
webpack:main
Choose a base branch
from
arkapratimc:issue-18895
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
04170ba
fixes #18895
arkapratimc bac375a
fix: conflicts
arkapratimc 8deed4f
fix: conflict
arkapratimc 871acee
chore: new public path function
arkapratimc 2edcce3
chore: lint
arkapratimc b33da07
chore: some replacements
arkapratimc ec897fd
mistake
arkapratimc 8a3728c
chore: replacements and fixes
arkapratimc 9f7da29
chore: lint
arkapratimc abe8a69
chore: type issue
arkapratimc 1ba4d98
chore: mistake
arkapratimc 6d5db06
chore: quote issue
arkapratimc 1863436
chore: snapshot
arkapratimc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
it("should handle different querystrings for assets correctly", () => { | ||
__webpack_public_path__ = (filename) => "hey/" + filename | ||
__webpack_base_uri__ = "https://example.com"; | ||
const file = new URL("../_images/file.png", import.meta.url); | ||
expect(file.href).toMatch(/^https:\/\/example.com\/hey\/[0-9a-f]+.png$/); | ||
}); |
3 changes: 3 additions & 0 deletions
3
test/configCases/asset-modules/dynamic-base-uri/webpack.config.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
target: "web" | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
it("should handle import.meta.url in URL()", () => { | ||
__webpack_public_path__ = (filename) => "hey/" + filename | ||
const url = new URL("./index.css?query=yes#fragment", import.meta.url); | ||
|
||
expect(url.href).toBe("hey/index.css?query=yes#fragment"); | ||
expect(url.origin).toBe(""); | ||
expect(url.protocol).toBe(""); | ||
expect(url.username).toBe(""); | ||
expec 9920 t(url.password).toBe(""); | ||
expect(url.host).toBe(""); | ||
expect(url.hostname).toBe(""); | ||
expect(url.port).toBe(""); | ||
expect(url.pathname).toBe("hey/index.css"); | ||
expect(url.search).toBe("?query=yes"); | ||
expect(url.searchParams.get("query")).toBe("yes"); | ||
expect(url.hash).toBe("#fragment"); | ||
expect(url + "").toBe("hey/index.css?query=yes#fragment"); | ||
expect(url.toString()).toBe("hey/index.css?query=yes#fragment"); | ||
expect(JSON.stringify(url)).toBe('"hey/index.css?query=yes#fragment"'); | ||
expect(url instanceof URL).toBe(true); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** @type {import("../../../../").Configuration} */ | ||
module.exports = { | ||
mode: "development", | ||
devtool: false, | ||
output: { | ||
assetModuleFilename: "[name][ext][query][fragment]" | ||
}, | ||
module: { | ||
parser: { | ||
javascript: { | ||
url: "relative" | ||
} | ||
} | ||
} | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should do it every where we have
RuntimeGlobals.publicPath