diff --git a/chompfile.toml b/chompfile.toml index 669b5900..0b44bea0 100644 --- a/chompfile.toml +++ b/chompfile.toml @@ -4,10 +4,14 @@ extensions = ['chomp@0.1:swc', 'chomp@0.1:rollup', 'chomp@0.1:prettier'] default-task = 'build' +[[task]] +target = 'lib' +deps = ['lib/**/*.js'] + [[task]] name = 'build' target = 'dist' -deps = ['lib', 'npm:install'] +deps = ['lib', 'npm:install', 'build:dec'] template = 'rollup' [task.template-options] input = [ @@ -24,8 +28,20 @@ clear-dir = true dir = 'dist' [[task]] -target = 'lib' -deps = ['lib/**/*.js'] +name = 'build:ts' +target = 'lib/##.js' +deps = ['src/##.ts'] +template = 'swc' +[task.template-options.config] +inlineSourcesContent = false +'jsc.target' = 'es2019' + +# TODO: We should emit declaration files with swc once they support it. +# See: https://github.com/swc-project/swc/issues/657 +[[task]] +name = 'build:dec' +deps = ['src/**/*.ts'] +run = 'tsc --emitDeclarationOnly' [[task]] target = 'lib/version.js' @@ -37,19 +53,6 @@ run = ''' writeFileSync('lib/version.js', `export default ${JSON.stringify(version)}`); ''' -[[task]] -name = 'build:ts' -target = 'lib/##.js' -deps = ['src/##.ts'] -template = 'swc' -[task.template-options.config] -inlineSourcesContent = false -'jsc.target' = 'es2019' - -[[task]] -name = 'test:unit' -dep = 'unit:' - [[task]] name = 'test' serial = true @@ -58,6 +61,10 @@ deps = [ 'test:browser', ] +[[task]] +name = 'test:unit' +dep = 'unit:' + [[task]] name = 'unit:#' deps = ['test/##.test.js', 'lib'] @@ -107,10 +114,10 @@ run = ''' [[task]] name = 'prettier' template = 'prettier' -deps = ['src/**/*', 'src/*', 'test/**/*', 'test/*'] +deps = ['src/**/*.ts', 'test/**/*.ts'] [task.template-options] ignore-path = '.prettierignore' -files = 'src/**/*.ts src/*.ts test/**/*.ts test/*' +files = 'src/**/*.ts test/**/*.ts' loglevel = 'warn' [[task]] diff --git a/package-lock.json b/package-lock.json index 66f2bdbc..7436a6e5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@babel/core": "^7.20.12", "@babel/plugin-syntax-import-assertions": "^7.20.0", "@babel/preset-typescript": "^7.18.6", - "@jspm/import-map": "^1.0.4", + "@jspm/import-map": "^1.0.5", "abort-controller": "^3.0.0", "es-module-lexer": "^1.1.1", "ipfs-client": "^0.9.2", @@ -32,7 +32,8 @@ "mocha": "^9.2.2", "open": "^8.4.1", "prettier": "^2.8.4", - "rollup": "^2.79.1" + "rollup": "^2.79.1", + "typescript": "^4.9.5" } }, "node_modules/@ampproject/remapping": { @@ -5127,6 +5128,19 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==" }, + "node_modules/typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/uint8arraylist": { "version": "2.4.3", "resolved": "https://registry.npmjs.org/uint8arraylist/-/uint8arraylist-2.4.3.tgz", diff --git a/package.json b/package.json index dc315053..37605523 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "Package Import Map Generation Tool", "license": "MIT", "version": "1.0.4", - "types": "src/generator.ts", + "types": "lib/generator.d.ts", "type": "module", "scripts": { "prepublishOnly": "chomp build" @@ -28,6 +28,10 @@ } }, "exports": { + "types": { + "deno": "./lib/generator-deno.d.ts", + "default": "./lib/generator.d.ts" + }, "source": { "deno": "./lib/generator-deno.js", "default": "./lib/generator.js" @@ -39,7 +43,7 @@ "@babel/core": "^7.20.12", "@babel/plugin-syntax-import-assertions": "^7.20.0", "@babel/preset-typescript": "^7.18.6", - "@jspm/import-map": "^1.0.4", + "@jspm/import-map": "^1.0.5", "abort-controller": "^3.0.0", "es-module-lexer": "^1.1.1", "ipfs-client": "^0.9.2", @@ -59,7 +63,8 @@ "mocha": "^9.2.2", "open": "^8.4.1", "prettier": "^2.8.4", - "rollup": "^2.79.1" + "rollup": "^2.79.1", + "typescript": "^4.9.5" }, "files": [ "dist", diff --git a/tsconfig.json b/tsconfig.json index 05fa1f05..1264b212 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,6 +8,7 @@ "sourceMap": true, "outDir": "lib", "declaration": true, + "declarationDir": "lib", "removeComments": false, "strictBindCallApply": true },