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

fix: config path problem on windows #4501

Merged
merged 2 commits into from May 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions cli/run/loadConfigFile.ts
@@ -1,4 +1,3 @@
import { promises as fs } from 'fs';
import { extname, isAbsolute } from 'path';
import { version } from 'process';
import { pathToFileURL } from 'url';
Expand Down Expand Up @@ -103,8 +102,8 @@ async function getDefaultFromTranspiledConfigFile(
return loadConfigFromBundledFile(fileName, code);
}

async function loadConfigFromBundledFile(fileName: string, bundledCode: string): Promise<unknown> {
const resolvedFileName = await fs.realpath(fileName);
function loadConfigFromBundledFile(fileName: string, bundledCode: string): unknown {
const resolvedFileName = require.resolve(fileName);
const extension = extname(resolvedFileName);
const defaultLoader = require.extensions[extension];
require.extensions[extension] = (module: NodeModule, requiredFileName: string) => {
Expand Down
11 changes: 11 additions & 0 deletions test/cli/samples/config-cwd-case-insensitive-es6/_config.js
@@ -0,0 +1,11 @@
function toggleCase(s) {
return s == s.toLowerCase() ? s.toUpperCase() : s.toLowerCase();
}

module.exports = {
onlyWindows: true,
description: "can load ES6 config with cwd that doesn't match realpath",
command: 'rollup -c',
cwd: __dirname.replace(/^[A-Z]:\\/i, toggleCase),
execute: true
};
1 change: 1 addition & 0 deletions test/cli/samples/config-cwd-case-insensitive-es6/main.js
@@ -0,0 +1 @@
assert.equal( ANSWER, 42 );
@@ -0,0 +1,9 @@
import replace from '@rollup/plugin-replace';

export default {
input: 'main.js',
output: {
format: 'cjs'
},
plugins: [replace({ preventAssignment: true, ANSWER: 42 })]
};