Skip to content
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

rollup-plugin-require-context not working properly in Windows system compile environment #17

Open
shenyi-dra opened this issue Apr 1, 2021 · 0 comments

Comments

@shenyi-dra
Copy link

shenyi-dra commented Apr 1, 2021

Hi elcarim, i have facing the below issue for my current usage in Windows System.

Based on the different path seperator, in mac or linux system, the sepatator is '/', but in Windows Systme, the path.sep is '\'.

In resolve-require-code.js, the genRequireCode will trying to generate the import strings
normal the require.context('packages/', true, /.vue$/) works on below folder structure.
eg.
pacakges/alert/src/index.vue
packages/button/src/index.vue

but in windows system case.
it will become
packages\alert\src\index.vue
pacakges\button\src\index.vue

and after the genRequireCode executed, the import string moduleProps will become below,
'./alert\src\index.vue': require_context_module_0_0,
'./button\src\index.vue': require_context_module_0_1'

And the keys methods the extract the keys from the import modules will trying to convert the string and get rid of the '\' in Windows System.

req.keys = function() {
   return Object.keys(map);
};

And at the end when i using the
const files = require.context('packages/', true, /.vue$/)
files.keys().forEach(key => {
console.log(key); // each key become ./alertsrcindex.vue, all the windows separator is get rid of by the Object.keys method.
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant