-
-
Notifications
You must be signed in to change notification settings - Fork 675
feat: Support import.meta.filename/dirname/resolve
#10573
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for rspack ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
CodSpeed Performance ReportMerging #10573 will not alter performanceComparing Summary
|
done. |
On Windows CI, - expect('file://<TEST_TOOLS_ROOT>/tests/builtinCases/plugin-javascript/import-meta/index.js').toBe(url);
- expect('file://<TEST_TOOLS_ROOT>/tests/builtinCases/plugin-javascript/import-meta/index.js').toBe(url);
- expect("my" + 'file://<TEST_TOOLS_ROOT>/tests/builtinCases/plugin-javascript/import-meta/index.js').toBe("my" + url);
+ expect('file:///<TEST_TOOLS_ROOT>/tests/builtinCases/plugin-javascript/import-meta/index.js').toBe(url);
+ expect('file:///<TEST_TOOLS_ROOT>/tests/builtinCases/plugin-javascript/import-meta/index.js').toBe(url);
+ expect("my" + 'file:///<TEST_TOOLS_ROOT>/tests/builtinCases/plugin-javascript/import-meta/index.js').toBe("my" + url); |
import.meta.filename
and import.meta.dirname
import.meta.filename/dirname/resolve
52a12d7
to
5837f13
Compare
"./tests/builtinCases/plugin-javascript/import-meta/index.js", | ||
).toString(); | ||
|
||
const filename = "/index.js"; |
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.
It appears that __filename
is handled by crates/rspack_plugin_rstest/src/parser_plugin.rs
using a different strategy.
.to_string() | ||
} | ||
|
||
// This is the same as the url.fileURLToPath() of the import.meta.url |
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.
Using PathBuf::from
directly might be more efficient. However, considering that the Resource
might contain a query string – which can introduce various edge cases like ./x.js?foo=/../y.js
– processing it through a URL parser is safer.
rspack/crates/rspack_loader_runner/src/content.rs
Lines 114 to 115 in 561581e
/// Resource with absolute path, query and fragment | |
pub resource: String, |
Summary
import.meta.resolve
+ Node Specific Meta Values #8008Checklist