Skip to content

Commit

Permalink
fix external module detection on Windows (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-type authored and jaredpalmer committed May 8, 2019
1 parent 5a5b9ac commit 78bb42f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/build-default/src/foo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const foo = () => 'bar';
2 changes: 2 additions & 0 deletions test/fixtures/build-default/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export { foo } from './foo';

export const sum = (a: number, b: number) => {
if ('development' === process.env.NODE_ENV) {
console.log('fuck');
Expand Down
9 changes: 9 additions & 0 deletions test/tests/tsdx-build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit 78bb42f

Please sign in to comment.