diff --git a/src/ExportsService.ts b/src/ExportsService.ts index 8f6f3c6..290d5ae 100644 --- a/src/ExportsService.ts +++ b/src/ExportsService.ts @@ -79,7 +79,8 @@ function relativize(path: string): string { } // Paths for emitted build files -// NOTE: the paths here are lifted to the root level (dist) +// NOTE: the paths here are ./dist if there are no root-entrypoints, +// and ./dist/src if there are. function tsToJs(file: string): string { return relativize(file.replace(/\.tsx?$/, '.js')) } diff --git a/tests/e2e.test.ts b/tests/e2e.test.ts index a9d56f2..9e60c25 100644 --- a/tests/e2e.test.ts +++ b/tests/e2e.test.ts @@ -31,10 +31,17 @@ describe('test projects', () => { // Used to test multi-entrypoint root based dual libs // ------------------------------------------------ 'multi-root-dual', + // + // NOTE: multi-entrypoint src based libs will not pass node-10 tests + // // ------------------------------------------------ // Used to test single-entrypoint src based dual libs // ------------------------------------------------ 'single-src-dual', + // ------------------------------------------------ + // Used to test single-entrypoint root based dual libs + // ------------------------------------------------ + 'single-root-dual', ]), ), )( diff --git a/tests/test-projects/single-root-dual/.gitignore b/tests/test-projects/single-root-dual/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/tests/test-projects/single-root-dual/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/tests/test-projects/single-root-dual/foo.foo.ts b/tests/test-projects/single-root-dual/foo.foo.ts new file mode 100644 index 0000000..0de7c69 --- /dev/null +++ b/tests/test-projects/single-root-dual/foo.foo.ts @@ -0,0 +1,11 @@ +import { bar } from './src/foo.bar.js' + +/** + * What is it? Who knows! + * + * @remarks + * I have nothing to say + */ +export const Foo = bar.baz === 'baz' ? 'bar' : 'foo' + +export type Bar = typeof bar diff --git a/tests/test-projects/single-root-dual/package.json b/tests/test-projects/single-root-dual/package.json new file mode 100644 index 0000000..25fd272 --- /dev/null +++ b/tests/test-projects/single-root-dual/package.json @@ -0,0 +1,7 @@ +{ + "name": "single-root-dual", + "version": "0.0.1", + "devDependencies": { + "@fp-tx/build-tools": "file:../../../dist" + } +} diff --git a/tests/test-projects/single-root-dual/src/baz.ts b/tests/test-projects/single-root-dual/src/baz.ts new file mode 100644 index 0000000..3e0c28b --- /dev/null +++ b/tests/test-projects/single-root-dual/src/baz.ts @@ -0,0 +1 @@ +export type Baz = { baz: 'baz' } diff --git a/tests/test-projects/single-root-dual/src/foo.bar.ts b/tests/test-projects/single-root-dual/src/foo.bar.ts new file mode 100644 index 0000000..43eaaf5 --- /dev/null +++ b/tests/test-projects/single-root-dual/src/foo.bar.ts @@ -0,0 +1,6 @@ +import { type Baz } from './baz.js' + +/** @public */ +export const bar: Baz = { + baz: 'baz', +} diff --git a/tests/test-projects/single-root-dual/tsconfig.json b/tests/test-projects/single-root-dual/tsconfig.json new file mode 100644 index 0000000..c91acac --- /dev/null +++ b/tests/test-projects/single-root-dual/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "module": "NodeNext", + "target": "ESNext", + "moduleResolution": "NodeNext", + "noEmit": true, + "strict": true, + "skipLibCheck": false, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "types": [] + }, + "include": ["./src/*.ts", "./*.ts"], + "exclude": [] +} diff --git a/tests/test-projects/single-root-dual/tsup.config.cjs b/tests/test-projects/single-root-dual/tsup.config.cjs new file mode 100644 index 0000000..ca52357 --- /dev/null +++ b/tests/test-projects/single-root-dual/tsup.config.cjs @@ -0,0 +1,19 @@ +const { makeConfig } = require('@fp-tx/build-tools') + +module.exports = makeConfig( + { + basePath: '.', + buildType: 'dual', + buildMode: { + type: 'Single', + entrypoint: './foo.foo.ts', + }, + srcDir: './src', + outDir: './dist', + copyFiles: [], + iife: true, + }, + { + clean: true, + }, +)