Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
lib/
spec/*.js
*.lsif
*.lsif
*.tgz
5 changes: 4 additions & 1 deletion .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"ui": "tdd",
"color": true,
"spec": "./lib/umd/test/*.test.js"
"spec": [
"./lib/cjs/test/*.test.js",
"./lib/esm/test/*.test.js"
]
}
9 changes: 0 additions & 9 deletions .npmignore

This file was deleted.

18 changes: 18 additions & 0 deletions fix-esm.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env node
import fs from 'node:fs/promises'

const outDir = new URL('lib/esm/', import.meta.url)
const pkg = {
type: 'module',
imports: {
'#path': {
browser: './path-browserify.js',
default: './path.js'
}
}
}

await fs.writeFile(
new URL('package.json', outDir),
JSON.stringify(pkg, undefined, 2) + '\n'
)
46 changes: 32 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,35 @@
"author": "Microsoft",
"version": "3.0.7",
"description": "The URI implementation that is used by VS Code and its extensions",
"main": "./lib/umd/index.js",
"typings": "./lib/umd/index",
"module": "./lib/esm/index.js",
"main": "./lib/cjs/index.js",
"exports": {
".": {
"import": "./lib/esm/index.js",
"default": "./lib/cjs/index.js"
}
},
"imports": {
"#path": {
"import": {
"browser": "./lib/esm/path-browserify.js",
"default": "./lib/esm/path.js"
},
"default": {
"browser": "./lib/cjs/path-browserify.js",
"default": "./lib/cjs/path.js"
}
}
},
"files": [
"lib",
"!lib/**/test",
"SECURITY.md"
],
"sideEffects": false,
"scripts": {
"clean": "rimraf lib",
"pack-production": "webpack --mode=production",
"pack-dev": "webpack",
"compile": "tsc -p ./src",
"prepublish": "npm run pack-production",
"test": "tsc -p ./src && npm run pack-dev && mocha"
"prepack": "npm run clean && tsc -b && node fix-esm.mjs",
"test": "npm run prepack && mocha"
},
"repository": {
"type": "git",
Expand All @@ -24,15 +42,15 @@
"url": "https://github.com/microsoft/vscode-uri/issues"
},
"homepage": "https://github.com/microsoft/vscode-uri#readme",
"dependencies": {
"path-browserify": "^1.0.1"
},
"devDependencies": {
"@types/mocha": "^9.1.1",
"@types/node": "16.x",
"@types/path-browserify": "^1.0.0",
"mocha": "^10.0.0",
"path-browserify": "^1.0.1",
"rimraf": "^3.0.2",
"ts-loader": "^9.3.1",
"typescript": "^4.8.3",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0"
"typescript": "^5.0.0"
}
}
}
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'use strict';

import { URI } from './uri';
import { Utils } from './utils';
import { URI } from './uri.js';
import { Utils } from './utils.js';

export { URI, Utils }
export { URI, Utils }
7 changes: 7 additions & 0 deletions src/path-browserify.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export {
basename,
dirname,
extname,
join,
resolve
} from 'path-browserify';
9 changes: 9 additions & 0 deletions src/path.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { posix } from 'path';

export const {
basename,
dirname,
extname,
join,
resolve
} = posix;
2 changes: 1 addition & 1 deletion src/test/paths.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import 'mocha';
import * as assert from 'assert';
import { URI, Utils } from '../index';
import { URI, Utils } from '../index.js';
import { posix } from 'path';

suite('URI path operations', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/test/uri.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { URI } from '../index';
import { isWindows } from '../platform';
import { URI } from '../index.js';
import { isWindows } from '../platform.js';

interface UriComponents {
scheme: string;
Expand Down
12 changes: 0 additions & 12 deletions src/tsconfig.json

This file was deleted.

4 changes: 2 additions & 2 deletions src/uri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*--------------------------------------------------------------------------------------------*/
'use strict';

import { CharCode } from './charCode'
import { isWindows } from './platform';
import { CharCode } from './charCode.js';
import { isWindows } from './platform.js';

const _schemePattern = /^\w[\w\d+.-]*$/;
const _singleSlashStart = /^\//;
Expand Down
9 changes: 4 additions & 5 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@

'use strict';

import { CharCode } from './charCode';
import { URI } from './uri';
import * as nodePath from 'path';
import { CharCode } from './charCode.js';
import { URI } from './uri.js';
import * as posixPath from '#path';

const posixPath = nodePath.posix || nodePath;
const slash = '/';

export namespace Utils {
Expand Down Expand Up @@ -101,4 +100,4 @@ export namespace Utils {
export function extname(uri: URI): string {
return posixPath.extname(uri.path);
}
}
}
8 changes: 8 additions & 0 deletions tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.esm.json",
"compilerOptions": {
"esModuleInterop": false,
"module": "node16",
"outDir": "./lib/cjs"
}
}
19 changes: 19 additions & 0 deletions tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"declaration": true,
"lib": [
"es2015"
],
"module": "esnext",
"moduleResolution": "node",
"noImplicitAny": true,
"outDir": "./lib/esm",
"paths": {
"#path": [
"./src/path.ts"
]
},
"rootDir": "./src",
"target": "es6",
}
}
7 changes: 7 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.cjs.json" },
{ "path": "./tsconfig.esm.json" }
]
}
104 changes: 0 additions & 104 deletions webpack.config.js

This file was deleted.

Loading