diff --git a/src/utils.ts b/src/utils.ts index 159ce1844..cae4164d1 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -17,7 +17,7 @@ export const safePackageName = (name: string) => name.toLowerCase().replace(/((^[^a-zA-Z]+)|[^\w.-])|([^a-zA-Z0-9]+$)/g, ''); export const external = (id: string) => - !id.startsWith('.') && !id.startsWith('/'); + !id.startsWith('.') && !path.isAbsolute(id); // Make sure any symlinks in the project folder are resolved: // https://github.com/facebookincubator/create-react-app/issues/637 diff --git a/test/fixtures/build-default/src/foo.ts b/test/fixtures/build-default/src/foo.ts new file mode 100644 index 000000000..0abb9556d --- /dev/null +++ b/test/fixtures/build-default/src/foo.ts @@ -0,0 +1 @@ +export const foo = () => 'bar'; diff --git a/test/fixtures/build-default/src/index.ts b/test/fixtures/build-default/src/index.ts index af27ae37d..b23b6213f 100644 --- a/test/fixtures/build-default/src/index.ts +++ b/test/fixtures/build-default/src/index.ts @@ -1,3 +1,5 @@ +export { foo } from './foo'; + export const sum = (a: number, b: number) => { if ('development' === process.env.NODE_ENV) { console.log('fuck'); diff --git a/test/tests/tsdx-build.test.js b/test/tests/tsdx-build.test.js index 6766ee66c..98c267f17 100644 --- a/test/tests/tsdx-build.test.js +++ b/test/tests/tsdx-build.test.js @@ -42,6 +42,15 @@ describe('tsdx build', () => { expect(output.code).toBe(0); }); + it('should create the library correctly', () => { + util.setupStageWithFixture(stageName, 'build-default'); + + shell.exec('node ../dist/index.js build'); + + const lib = require(`../../${stageName}/dist`); + expect(lib.foo()).toBe('bar'); + }); + afterEach(() => { util.teardownStage(stageName); });