-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(paths): Refactor Paths handling (#80)
* fix(paths): Refactor paths handling to suport js along with plain non path paths * tests(js,ts): Add extension and extensionless path tests * chore(names): rename debugging const
- Loading branch information
Showing
33 changed files
with
366 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "js-nonextpaths", | ||
"type": "module", | ||
"main": "./src/index.ts", | ||
"NODE_OPTIONS": "--harmony-top-level-await", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"start": "node --loader ../../../out/dist/index.js --experimental-specifier-resolution=node --experimental-import-meta-resolve --harmony-optional-chaining --harmony-top-level-await src/index.ts" | ||
}, | ||
"author": "", | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Testing/Tests/src/Module/HelloWorld/index.ts | ||
import { add } from '@paths/Utils/Math'; | ||
|
||
export async function testingSubPath(): Promise<number> { | ||
return add(1, 5); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Testing/Tests/JSPaths/src/Module/Random/index.ts | ||
import { sayRandom } from 'random'; | ||
|
||
export async function randomModule(): Promise<string> { | ||
return sayRandom(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Testing/Tests/Lab/src/Utils/Math.ts | ||
|
||
export function add(x: number, y: number): number { | ||
console.debug(`Adding ${x} + ${y}`); | ||
|
||
return x + y; | ||
} | ||
|
||
export function divide(x: number, y: number): number { | ||
console.debug(`Dividing ${x} / ${y}`); | ||
|
||
return x / y; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Testing/Tests/JSPaths/src/Utils/random.js | ||
export function sayRandom() { | ||
return 'random'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Testing/Tests/Lab/src/index.ts | ||
import { add, divide } from '@paths/Utils/Math'; | ||
import { strictEqual } from 'assert'; | ||
|
||
export async function startApp(): Promise<void> { | ||
console.debug('Starting Application'); | ||
|
||
const sum = add(1, 1); | ||
strictEqual(sum, 2); | ||
|
||
const divideResult = divide(2, 2); | ||
strictEqual(divideResult, 1); | ||
|
||
const { testingSubPath } = await import('@paths/Module/HelloWorld'); | ||
|
||
const addSub = await testingSubPath(); | ||
strictEqual(addSub, 6); | ||
|
||
const { randomModule } = await import('@paths/Module/Random'); | ||
|
||
const randomResult = await randomModule(); | ||
strictEqual(randomResult, 'random'); | ||
|
||
console.debug('Done'); | ||
} | ||
|
||
startApp(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleResolution": "Node", | ||
"allowSyntheticDefaultImports": true, | ||
"baseUrl": "./src", | ||
|
||
"allowJs": true, | ||
"paths": { | ||
"@paths/*": ["./*"], | ||
"random": ["./Utils/random"] | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "js-paths", | ||
"type": "module", | ||
"main": "./src/index.ts", | ||
"NODE_OPTIONS": "--harmony-top-level-await", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"start": "node --loader ../../../out/dist/index.js --experimental-specifier-resolution=node --experimental-import-meta-resolve --harmony-optional-chaining --harmony-top-level-await src/index.ts" | ||
}, | ||
"author": "", | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Testing/Tests/src/Module/HelloWorld/index.ts | ||
import { add } from '@paths/Utils/Math'; | ||
|
||
export async function testingSubPath(): Promise<number> { | ||
return add(1, 5); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Testing/Tests/JSPaths/src/Module/Random/index.ts | ||
import { sayRandom } from 'random'; | ||
|
||
export async function randomModule(): Promise<string> { | ||
return sayRandom(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Testing/Tests/Lab/src/Utils/Math.ts | ||
|
||
export function add(x: number, y: number): number { | ||
console.debug(`Adding ${x} + ${y}`); | ||
|
||
return x + y; | ||
} | ||
|
||
export function divide(x: number, y: number): number { | ||
console.debug(`Dividing ${x} / ${y}`); | ||
|
||
return x / y; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Testing/Tests/JSPaths/src/Utils/random.js | ||
export function sayRandom() { | ||
return 'random'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Testing/Tests/Lab/src/index.ts | ||
import { add, divide } from '@paths/Utils/Math'; | ||
import { strictEqual } from 'assert'; | ||
|
||
export async function startApp(): Promise<void> { | ||
console.debug('Starting Application'); | ||
|
||
const sum = add(1, 1); | ||
strictEqual(sum, 2); | ||
|
||
const divideResult = divide(2, 2); | ||
strictEqual(divideResult, 1); | ||
|
||
const { testingSubPath } = await import('@paths/Module/HelloWorld'); | ||
|
||
const addSub = await testingSubPath(); | ||
strictEqual(addSub, 6); | ||
|
||
const { randomModule } = await import('@paths/Module/Random'); | ||
|
||
const randomResult = await randomModule(); | ||
strictEqual(randomResult, 'random'); | ||
|
||
console.debug('Done'); | ||
} | ||
|
||
startApp(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleResolution": "Node", | ||
"allowSyntheticDefaultImports": true, | ||
"baseUrl": "./src", | ||
|
||
"allowJs": true, | ||
"paths": { | ||
"@paths/*": ["./*"], | ||
"random": ["./Utils/random.js"] | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "ts-extpaths", | ||
"type": "module", | ||
"main": "./src/index.ts", | ||
"NODE_OPTIONS": "--harmony-top-level-await", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"start": "node --loader ../../../out/dist/index.js --experimental-specifier-resolution=node --experimental-import-meta-resolve --harmony-optional-chaining --harmony-top-level-await src/index.ts" | ||
}, | ||
"author": "", | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Testing/Tests/src/Module/HelloWorld/index.ts | ||
import { add } from '@paths/Utils/Math'; | ||
|
||
export async function testingSubPath(): Promise<number> { | ||
return add(1, 5); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Testing/Tests/JSPaths/src/Module/Random/index.ts | ||
import { sayRandom } from 'random'; | ||
|
||
export async function randomModule(): Promise<string> { | ||
return sayRandom(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Testing/Tests/Lab/src/Utils/Math.ts | ||
|
||
export function add(x: number, y: number): number { | ||
console.debug(`Adding ${x} + ${y}`); | ||
|
||
return x + y; | ||
} | ||
|
||
export function divide(x: number, y: number): number { | ||
console.debug(`Dividing ${x} / ${y}`); | ||
|
||
return x / y; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Testing/Tests/JSPaths/src/Utils/random.js | ||
export function sayRandom(): 'random' { | ||
return 'random'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Testing/Tests/Lab/src/index.ts | ||
import { add, divide } from '@paths/Utils/Math'; | ||
import { strictEqual } from 'assert'; | ||
|
||
export async function startApp(): Promise<void> { | ||
console.debug('Starting Application'); | ||
|
||
const sum = add(1, 1); | ||
strictEqual(sum, 2); | ||
|
||
const divideResult = divide(2, 2); | ||
strictEqual(divideResult, 1); | ||
|
||
const { testingSubPath } = await import('@paths/Module/HelloWorld'); | ||
|
||
const addSub = await testingSubPath(); | ||
strictEqual(addSub, 6); | ||
|
||
const { randomModule } = await import('@paths/Module/Random'); | ||
|
||
const randomResult = await randomModule(); | ||
console.log('randomResult: ', randomResult); | ||
|
||
strictEqual(randomResult, 'random'); | ||
|
||
console.debug('Done'); | ||
} | ||
|
||
startApp(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleResolution": "Node", | ||
"allowSyntheticDefaultImports": true, | ||
"baseUrl": "./src", | ||
|
||
"allowJs": true, | ||
"paths": { | ||
"@paths/*": ["./*"], | ||
"random": ["./Utils/random.ts"] | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "ts-nonextpaths", | ||
"type": "module", | ||
"main": "./src/index.ts", | ||
"NODE_OPTIONS": "--harmony-top-level-await", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"start": "node --loader ../../../out/dist/index.js --experimental-specifier-resolution=node --experimental-import-meta-resolve --harmony-optional-chaining --harmony-top-level-await src/index.ts" | ||
}, | ||
"author": "", | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Testing/Tests/src/Module/HelloWorld/index.ts | ||
import { add } from '@paths/Utils/Math'; | ||
|
||
export async function testingSubPath(): Promise<number> { | ||
return add(1, 5); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Testing/Tests/JSPaths/src/Module/Random/index.ts | ||
import { sayRandom } from 'random'; | ||
|
||
export async function randomModule(): Promise<string> { | ||
return sayRandom(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Testing/Tests/Lab/src/Utils/Math.ts | ||
|
||
export function add(x: number, y: number): number { | ||
console.debug(`Adding ${x} + ${y}`); | ||
|
||
return x + y; | ||
} | ||
|
||
export function divide(x: number, y: number): number { | ||
console.debug(`Dividing ${x} / ${y}`); | ||
|
||
return x / y; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Testing/Tests/JSPaths/src/Utils/random.js | ||
export function sayRandom(): 'random' { | ||
return 'random'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Testing/Tests/Lab/src/index.ts | ||
import { add, divide } from '@paths/Utils/Math'; | ||
import { strictEqual } from 'assert'; | ||
|
||
export async function startApp(): Promise<void> { | ||
console.debug('Starting Application'); | ||
|
||
const sum = add(1, 1); | ||
strictEqual(sum, 2); | ||
|
||
const divideResult = divide(2, 2); | ||
strictEqual(divideResult, 1); | ||
|
||
const { testingSubPath } = await import('@paths/Module/HelloWorld'); | ||
|
||
const addSub = await testingSubPath(); | ||
strictEqual(addSub, 6); | ||
|
||
const { randomModule } = await import('@paths/Module/Random'); | ||
|
||
const randomResult = await randomModule(); | ||
console.log('randomResult: ', randomResult); | ||
|
||
strictEqual(randomResult, 'random'); | ||
|
||
console.debug('Done'); | ||
} | ||
|
||
startApp(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleResolution": "Node", | ||
"allowSyntheticDefaultImports": true, | ||
"baseUrl": "./src", | ||
|
||
"allowJs": true, | ||
"paths": { | ||
"@paths/*": ["./*"], | ||
"random": ["./Utils/random"] | ||
} | ||
} | ||
} |
Oops, something went wrong.