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

preserveModulesRoot of vite configuration file is invalid in windows #6509

Closed
7 tasks done
ckvv opened this issue Jan 14, 2022 · 4 comments
Closed
7 tasks done

preserveModulesRoot of vite configuration file is invalid in windows #6509

ckvv opened this issue Jan 14, 2022 · 4 comments
Labels
bug: upstream Bug in a dependency of Vite windows only

Comments

@ckvv
Copy link

ckvv commented Jan 14, 2022

Describe the bug

preserveModulesRoot of vite configuration file is invalid in windows

in windows (The src directory should not exist in the es directory)

in macos
截屏2022-01-14 下午10 53 23

Reproduction

https://github.com/ckpack/v-ui

System Info

System:
    OS: Windows 10 10.0.19042
    CPU: (8) x64 Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz
    Memory: 8.44 GB / 15.83 GB
  Binaries:
    Node: 14.17.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.11 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 7.22.0 - ~\AppData\Roaming\npm\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (97.0.1072.55)
    Internet Explorer: 11.0.19041.1202
  npmPackages:
    @vitejs/plugin-vue: ^2.0.1 => 2.0.1
    vite: ^2.7.10 => 2.7.12

Used Package Manager

pnpm

Logs

No response

Validations

@sapphi-red
Copy link
Member

This seems to be an upstream issue.
rollup/rollup#4496

@sapphi-red sapphi-red added bug: upstream Bug in a dependency of Vite and removed pending triage labels Jul 10, 2022
@cleverpp
Copy link

+1, i have same problem。

after debugging, I found that it is caused by the following code

at 'rollup/src/utils/options/normalizeOutputOptions.ts'

...
preserveModulesRoot: getPreserveModulesRoot(config),
....

const getPreserveModulesRoot = (
	config: OutputOptions
): NormalizedOutputOptions['preserveModulesRoot'] => {
	const { preserveModulesRoot } = config;
	if (preserveModulesRoot === null || preserveModulesRoot === undefined) {
		return undefined;
	}
	return resolve(preserveModulesRoot);
};

but, at ''src/chunk.ts" 中

const currentPath = `${currentDir}/${fileName}`;
const { preserveModulesRoot } = options;
if (preserveModulesRoot && currentPath.startsWith(preserveModulesRoot)) {
	path = currentPath.slice(preserveModulesRoot.length).replace(/^[\\/]/, '');
} else {
	path = relative(preserveModulesRelativeDir, currentPath);
}

currentPath not resolve, but preserveModulesRoot had resolve, so in windows platform,currentPath.startsWith(preserveModulesRoot) always be false。

@Tanimodori
Copy link

This is due to vite normalized the slashs while rollup leaves it platform-dependent. See the complete comment here: rollup/rollup#4591 (comment)

@Tanimodori
Copy link

This issue is fixed in rollup 2.77.3

@github-actions github-actions bot locked and limited conversation to collaborators Aug 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug: upstream Bug in a dependency of Vite windows only
Projects
None yet
Development

No branches or pull requests

5 participants