Skip to content

Commit

Permalink
engage typescript conditions when typescript parent path is detected
Browse files Browse the repository at this point in the history
  • Loading branch information
bumblehead committed Sep 12, 2023
1 parent 18c670b commit 8c98b65
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 8 deletions.
12 changes: 9 additions & 3 deletions tests/tests-basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@
"nodejsexample_12_exports": "file:nodejsexample_12_exports",
"resolvewithplus": "file:.."
},
"workspaces": ["workspaces/*"],
"workspaces": [
"workspaces-js/*",
"workspaces-ts/*"
],
"scripts": {
"test-workspace": "npm --prefix workspaces/b test",
"test": "node --experimental-import-meta-resolve --test tests-basic.test.js tests-export-patterns.test.js tests-import-patterns.test.js"
"test-workspaces-js": "npm --prefix workspaces-js/js-b test",
"test-workspaces-ts": "npm --prefix workspaces-ts/ts-b test",
"test-workspaces": "npm run test-workspaces-js && npm run test-workspaces-ts",
"test-vanilla": "node --experimental-import-meta-resolve --test tests-basic.test.js tests-export-patterns.test.js tests-import-patterns.test.js",
"test": "npm run test-workspaces && npm run test-vanilla"
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "a",
"name": "js-a",
"version": "0.0.0",
"type": "module",
"main": "index.js"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "b",
"name": "js-b",
"version": "0.0.0",
"type": "module",
"scripts": {
"test": "node --experimental-import-meta-resolve --test"
},
"dependencies": {
"a": "^0.0.0"
"js-a": "^0.0.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import resolvewithplus from '../../../../resolvewithplus.js'

test('should return workspace paths', () => {
assert.strictEqual(
import.meta.resolve('a'),
resolvewithplus('a'))
import.meta.resolve('js-a'),
resolvewithplus('js-a'))
})
3 changes: 3 additions & 0 deletions tests/tests-basic/workspaces-ts/ts-a/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function foo () {
return 'foo'
}
6 changes: 6 additions & 0 deletions tests/tests-basic/workspaces-ts/ts-a/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "ts-a",
"version": "0.0.0",
"type": "module",
"main": "index.js"
}
5 changes: 5 additions & 0 deletions tests/tests-basic/workspaces-ts/ts-b/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {foo} from 'a'

export default function test () {
return foo()
}
14 changes: 14 additions & 0 deletions tests/tests-basic/workspaces-ts/ts-b/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "ts-b",
"version": "0.0.0",
"type": "module",
"scripts": {
"test": "node --loader=ts-node/esm --test test.ts"
},
"dependencies": {
"ts-a": "^0.0.0"
},
"devDependencies": {
"ts-node": "^10.9.1"
}
}
12 changes: 12 additions & 0 deletions tests/tests-basic/workspaces-ts/ts-b/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import resolvewithplus from '../../../../resolvewithplus.js'

console.log('test here!')
/*
test('should return workspace paths', () => {
assert.strictEqual(
import.meta.resolve('ts-a'),
resolvewithplus('ts-a'))
})
*/
8 changes: 8 additions & 0 deletions tests/tests-basic/workspaces-ts/ts-b/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"esm": true,
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"module": "ESNext",
"moduleResolution": "node"
}
}

0 comments on commit 8c98b65

Please sign in to comment.