Skip to content

Commit 6aa3a66

Browse files
committed
Make vs/base/common/path compatible with ESM
1 parent 95e1e94 commit 6aa3a66

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

src/vs/base/common/path.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,7 @@ interface IPath {
205205
posix: IPath | null;
206206
}
207207

208-
interface IExportedPath extends IPath {
209-
win32: IPath;
210-
posix: IPath;
211-
}
212-
213-
const win32: IPath = {
208+
export const win32: IPath = {
214209
// path.resolve([from ...], to)
215210
resolve(...pathSegments: string[]): string {
216211
let resolvedDevice = '';
@@ -1199,7 +1194,7 @@ const win32: IPath = {
11991194
posix: null
12001195
};
12011196

1202-
const posix: IPath = {
1197+
export const posix: IPath = {
12031198
// path.resolve([from ...], to)
12041199
resolve(...pathSegments: string[]): string {
12051200
let resolvedPath = '';
@@ -1685,5 +1680,16 @@ const posix: IPath = {
16851680
posix.win32 = win32.win32 = win32;
16861681
posix.posix = win32.posix = posix;
16871682

1688-
const impl = (safeProcess.platform === 'win32' ? win32 : posix) as IExportedPath;
1689-
export = impl;
1683+
export const normalize = (safeProcess.platform === 'win32' ? win32.normalize : posix.normalize);
1684+
export const isAbsolute = (safeProcess.platform === 'win32' ? win32.isAbsolute : posix.isAbsolute);
1685+
export const join = (safeProcess.platform === 'win32' ? win32.join : posix.join);
1686+
export const resolve = (safeProcess.platform === 'win32' ? win32.resolve : posix.resolve);
1687+
export const relative = (safeProcess.platform === 'win32' ? win32.relative : posix.relative);
1688+
export const dirname = (safeProcess.platform === 'win32' ? win32.dirname : posix.dirname);
1689+
export const basename = (safeProcess.platform === 'win32' ? win32.basename : posix.basename);
1690+
export const extname = (safeProcess.platform === 'win32' ? win32.extname : posix.extname);
1691+
export const format = (safeProcess.platform === 'win32' ? win32.format : posix.format);
1692+
export const parse = (safeProcess.platform === 'win32' ? win32.parse : posix.parse);
1693+
export const toNamespacedPath = (safeProcess.platform === 'win32' ? win32.toNamespacedPath : posix.toNamespacedPath);
1694+
export const sep = (safeProcess.platform === 'win32' ? win32.sep : posix.sep);
1695+
export const delimiter = (safeProcess.platform === 'win32' ? win32.delimiter : posix.delimiter);

0 commit comments

Comments
 (0)