From 77bc99e405986a8a74cc13f53dd21ad47bb90287 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Fri, 26 Apr 2019 14:22:12 -0700 Subject: [PATCH] fix: Don't mix generated declaration files with ts source files. TypeScript seems to get confused when a .d.ts and a .ts file of the same basename are in the same directory. This causes a consuming project to think it needs to compile the *.ts files that are imported from the index.d.ts file. Also did some other maintainance while I was here: * use yarn instead of npm for script execution. * enable sourcemaps so consuming projects will see the right source when navigating code and so debugging sessions can navigate the typescript code. * Update engine support to exlude node 11 now that 12 is released. --- .gitignore | 3 ++- package.json | 11 ++++++----- {lib => src}/entry.ts | 0 {lib => src}/index.ts | 0 {lib => src}/util.ts | 0 tests/entry-test.ts | 2 +- tests/fs-tree-test.ts | 4 ++-- tests/util-test.ts | 4 ++-- tsconfig.publish.json | 19 +++++++++++++++++++ yarn.lock | 24 ++++++++++++------------ 10 files changed, 44 insertions(+), 23 deletions(-) rename {lib => src}/entry.ts (100%) rename {lib => src}/index.ts (100%) rename {lib => src}/util.ts (100%) create mode 100644 tsconfig.publish.json diff --git a/.gitignore b/.gitignore index eb5fe97..7095d8d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ node_modules tmp +lib *.js *.d.ts -!types/ \ No newline at end of file +!types/ diff --git a/package.json b/package.json index f3f9632..e25599f 100644 --- a/package.json +++ b/package.json @@ -5,14 +5,15 @@ "main": "lib/index.js", "types": "lib/index.d.ts", "files": [ - "lib" + "lib", + "src" ], "scripts": { - "test": "npm run test:js", + "test": "yarn run test:js", "test:js": "mocha --require ts-node/register tests/*-test.ts", "test:js:debug": "mocha debug --require ts-node/register tests/*-test.ts", - "build": "tsc", - "prepublish": "tsc" + "build": "tsc --build tsconfig.publish.json", + "prepublish": "tsc --build tsconfig.publish.json" }, "keywords": [ "broccoli" @@ -20,7 +21,6 @@ "author": "Stefan Penner, David J. Hamilton, Chad Hietala", "license": "MIT", "dependencies": { - "@types/symlink-or-copy": "^1.2.0", "heimdalljs-logger": "^0.1.7", "object-assign": "^4.1.0", "path-posix": "^1.0.0", @@ -31,6 +31,7 @@ "@types/fs-extra": "^5.0.4", "@types/mocha": "^5.2.5", "@types/node": "^10.12.21", + "@types/symlink-or-copy": "^1.2.0", "chai": "^3.3.0", "fs-extra": "^1.0.0", "mocha": "^2.3.3", diff --git a/lib/entry.ts b/src/entry.ts similarity index 100% rename from lib/entry.ts rename to src/entry.ts diff --git a/lib/index.ts b/src/index.ts similarity index 100% rename from lib/index.ts rename to src/index.ts diff --git a/lib/util.ts b/src/util.ts similarity index 100% rename from lib/util.ts rename to src/util.ts diff --git a/tests/entry-test.ts b/tests/entry-test.ts index 3001e15..2283497 100644 --- a/tests/entry-test.ts +++ b/tests/entry-test.ts @@ -1,6 +1,6 @@ import fs = require('fs-extra'); import chai = require('chai'); -import Entry from '../lib/entry'; +import Entry from '../src/entry'; const { expect } = chai; const FIXTURE_DIR = 'fixture'; diff --git a/tests/fs-tree-test.ts b/tests/fs-tree-test.ts index 5d44ea1..eca4cf3 100644 --- a/tests/fs-tree-test.ts +++ b/tests/fs-tree-test.ts @@ -2,8 +2,8 @@ import fs = require('fs-extra'); import path = require('path'); import chai = require('chai'); import walkSync = require('walk-sync'); -import FSTree = require('../lib/index'); -import Entry from '../lib/entry'; +import FSTree = require('../src/index'); +import Entry from '../src/entry'; const { expect } = chai; const context = describe; diff --git a/tests/util-test.ts b/tests/util-test.ts index 6f7c39c..58bfe4f 100644 --- a/tests/util-test.ts +++ b/tests/util-test.ts @@ -4,8 +4,8 @@ import { basename, computeImpliedEntries, sortAndExpand -} from '../lib/util'; -import Entry from '../lib/entry'; +} from '../src/util'; +import Entry from '../src/entry'; const { expect } = chai; diff --git a/tsconfig.publish.json b/tsconfig.publish.json new file mode 100644 index 0000000..580e10e --- /dev/null +++ b/tsconfig.publish.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "composite": true, + "rootDir": "src", + "outDir": "lib", + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "strict": true, + "moduleResolution": "node", + "module": "commonjs", + "target": "es5", + "paths": { + "*": ["types/*"] + }, + "baseUrl": "." + }, + "include": ["src"] +} diff --git a/yarn.lock b/yarn.lock index b876fb3..3708359 100644 --- a/yarn.lock +++ b/yarn.lock @@ -250,9 +250,9 @@ sigmund@~1.0.0: resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590" source-map-support@^0.5.6: - version "0.5.10" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.10.tgz#2214080bc9d51832511ee2bab96e3c2f9353120c" - integrity sha512-YfQ3tQFTK/yzlGJuX8pTwa4tifQj4QS2Mj7UegOu8jAz59MqIiMGPXxQhVQiIMNzayuUSF/jEuVnfFF5JqybmQ== + version "0.5.12" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.12.tgz#b4f3b10d51857a5af0138d3ce8003b201613d599" + integrity sha512-4h2Pbvyy15EE02G+JOZpUCmqWJuqrs+sEkzewTm++BPi7Hvn/HwcqLAcNxYAyI0x13CpPPn+kMjl+hplXMHITQ== dependencies: buffer-from "^1.0.0" source-map "^0.6.0" @@ -275,9 +275,9 @@ to-iso-string@0.0.2: resolved "https://registry.yarnpkg.com/to-iso-string/-/to-iso-string-0.0.2.tgz#4dc19e664dfccbe25bd8db508b00c6da158255d1" ts-node@^8.0.2: - version "8.0.2" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.0.2.tgz#9ecdf8d782a0ca4c80d1d641cbb236af4ac1b756" - integrity sha512-MosTrinKmaAcWgO8tqMjMJB22h+sp3Rd1i4fdoWY4mhBDekOwIAKI/bzmRi7IcbCmjquccYg2gcF6NBkLgr0Tw== + version "8.1.0" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.1.0.tgz#8c4b37036abd448577db22a061fd7a67d47e658e" + integrity sha512-34jpuOrxDuf+O6iW1JpgTRDFynUZ1iEqtYruBqh35gICNjN8x+LpVcPAcwzLPi9VU6mdA3ym+x233nZmZp445A== dependencies: arg "^4.1.0" diff "^3.1.0" @@ -294,9 +294,9 @@ type-detect@^1.0.0: resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-1.0.0.tgz#762217cc06db258ec48908a1298e8b95121e8ea2" typescript@^3.3.3: - version "3.3.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.3.3.tgz#f1657fc7daa27e1a8930758ace9ae8da31403221" - integrity sha512-Y21Xqe54TBVp+VDSNbuDYdGw0BpoR/Q6wo/+35M8PAU0vipahnyduJWirxxdxjsAkS7hue53x2zp8gz7F05u0A== + version "3.4.5" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.4.5.tgz#2d2618d10bb566572b8d7aad5180d84257d70a99" + integrity sha512-YycBxUb49UUhdNMU5aJ7z5Ej2XGmaIBL0x34vZ82fn3hGvD+bgrMrVDpatgz2f7YxUMJxMkbWxJZeAvDxVe7Vw== walk-sync@^0.3.1: version "0.3.4" @@ -306,6 +306,6 @@ walk-sync@^0.3.1: matcher-collection "^1.0.0" yn@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/yn/-/yn-3.0.0.tgz#0073c6b56e92aed652fbdfd62431f2d6b9a7a091" - integrity sha512-+Wo/p5VRfxUgBUGy2j/6KX2mj9AYJWOHuhMjMcbBFc3y54o9/4buK1ksBvuiK01C3kby8DH9lSmJdSxw+4G/2Q== + version "3.1.0" + resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.0.tgz#fcbe2db63610361afcc5eb9e0ac91e976d046114" + integrity sha512-kKfnnYkbTfrAdd0xICNFw7Atm8nKpLcLv9AZGEt+kczL/WQVai4e2V6ZN8U/O+iI6WrNuJjNNOyu4zfhl9D3Hg==