require.context replacement doesn't work for nested paths on Windows
See original GitHub issueThis plugin will rewrite the following
const customTabsContext = require.context('@/components/tabs', true, /^.*(.vue)$/)
to something like this when using Windows:
const customTabsContext =
(function() {
var map = {
'./category1\Tab1.vue': import_context_module_0_0,
'./category1\Tab2.vue': import_context_module_0_1,
'./category2\Tab3.vue': import_context_module_0_2,
};
var req = function req(key) {
return map[key] || (function() { throw new Error("Cannot find module '" + key + "'.") }());
}
req.keys = function() {
return Object.keys(map);
}
return req;
})()
Note that the keys in the map use backslashes \ for nested paths. However to put a backslash into a string literal you need to escape it \\. Therefore require.context won’t work for nested paths on Windows.
This works fine on Mac OS, as the keys in the map will use forward slashes /.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Building context-nested routes with React Router 6
The issue here is that the code is attempting to render two routes on the same path, but only one route can match...
Read more >possibility to use nested routes with absolute paths ... - GitHub
I'm implementing i18n, my URLs are translated and I have to work with absolute addresses, because the translation library doesn't have access to ......
Read more >Resolve | webpack
A list of directories where requests of server-relative URLs (starting with '/') are resolved, defaults to context configuration option. On non-Windows systems ...
Read more >Analyze complex data types in Azure Synapse Analytics
Analyzing nested schema and arrays can involve time-consuming and complex ... deeply nested objects, you can encounter performance problems.
Read more >Migrating to React Router v6: A complete guide
Thus, developers need to arrange the definition, so the route with the parameter comes first. Otherwise, the routes won't work as expected ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Release: v0.3.2
BTW I change src/lib/resolve.ts#L100 to pass my testcase, if something wrong, please feedback.
Will give this a go tomorrow. Thanks for creating this awesome plug-in!