Skip to content

Commit

Permalink
Transpile using TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
Acconut committed Apr 16, 2024
1 parent 2d64821 commit f16b675
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 12 deletions.
1 change: 1 addition & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Type definitions for tus-js-client
// TODO: Remove this file

export const isSupported: boolean
export const canStoreURLs: boolean
Expand Down
1 change: 1 addition & 0 deletions lib/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// This is a test file for ensuring that the type definitions in index.d.ts are
// working correctly. For more details see:
// https://github.com/SamVerschueren/tsd
// TODO: Remove this file

import * as tus from '../'
import { expectType } from 'tsd'
Expand Down
4 changes: 3 additions & 1 deletion lib/upload.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/* eslint-disable import/no-unresolved */
/* eslint-disable import/extensions */
import { Base64 } from 'js-base64'
import URL from 'url-parse'
import DetailedError from './error.js'
import { log } from './logger.js'
import uuid from './uuid.ts'
import uuid from './uuid'

const PROTOCOL_TUS_V1 = 'tus-v1'
const PROTOCOL_IETF_DRAFT_03 = 'ietf-draft-03'
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"temp": "^0.9.4",
"throttle": "^1.0.3",
"tsd": "0.31.0",
"typescript": "^5.4.5",
"uglify-js": "^3.9.2"
},
"dependencies": {
Expand All @@ -90,12 +91,12 @@
},
"scripts": {
"build-test-bundle": "mkdir -p dist && browserify test/spec/browser-index.js -t [ babelify --plugins [ @babel/transform-modules-commonjs ] ] -d -o dist/browser-test-bundle.js",
"build-bundle": "mkdir -p dist && browserify lib/browser/index.js -t [ babelify --plugins [ @babel/transform-modules-commonjs ] ] -s tus -d | exorcist ./dist/tus.js.map > dist/tus.js",
"build-bundle": "mkdir -p dist && browserify lib.es5/browser/index.js -s tus -d | exorcist ./dist/tus.js.map > dist/tus.js",
"build-minify": "uglifyjs ./dist/tus.js -o ./dist/tus.min.js --compress --mangle --source-map \"content='./dist/tus.js.map',url='tus.min.js.map'\"",
"build-transpile-esm": "babel -d lib.esm/ lib/",
"build-transpile-cjs": "babel --no-babelrc --plugins @babel/transform-modules-commonjs -d lib.es5/ lib.esm/",
"build-transpile-esm": "tsc --project tsconfig-esm.json",
"build-transpile-cjs": "tsc --project tsconfig-cjs.json",
"build-transpile": "npm-run-all build-transpile-esm build-transpile-cjs",
"build": "npm-run-all build-bundle build-minify build-transpile build-test-bundle",
"build": "npm-run-all build-transpile build-bundle build-minify build-test-bundle",
"watch-bundle": "chokidar --initial \"lib/**/*\" -c \"npm run build-bundle\"",
"watch-test-bundle": "chokidar --initial \"test/spec/**/*\" -c \"npm run build-test-bundle\"",
"watch-transpile": "chokidar --initial \"lib/**/*\" -c \"npm run build-transpile\"",
Expand Down
14 changes: 14 additions & 0 deletions tsconfig-base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"include": ["lib/**/*"],
"exclude": ["lib/index.d.ts", "lib/index.test-d.ts"],
"compilerOptions": {
"target": "ES2018",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"allowJs": true,
"checkJs": false,
"declaration": true
}
}
8 changes: 8 additions & 0 deletions tsconfig-cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig-base.json",
"compilerOptions": {
"module": "commonjs",
// TODO: Rename to lib.cjs
"outDir": "lib.es5"
}
}
7 changes: 7 additions & 0 deletions tsconfig-esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig-base.json",
"compilerOptions": {
"module": "ES2015",
"outDir": "lib.esm/"
}
}
7 changes: 0 additions & 7 deletions tsconfig.json

This file was deleted.

5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6606,6 +6606,11 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=

typescript@^5.4.5:
version "5.4.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.5.tgz#42ccef2c571fdbd0f6718b1d1f5e6e5ef006f611"
integrity sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==

ua-parser-js@^0.7.30:
version "0.7.33"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.33.tgz#1d04acb4ccef9293df6f70f2c3d22f3030d8b532"
Expand Down

0 comments on commit f16b675

Please sign in to comment.