This is an automated email from the ASF dual-hosted git repository. gerben pushed a commit to branch typescript in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git
commit 3d8739d39dbc75a7f7558481aef5a5da2881d0bf Author: Gerben <[email protected]> AuthorDate: Thu Apr 16 18:02:03 2020 +0200 Configure for typescript --- .mocharc.js | 2 +- babel-register.js | 3 +++ babel.config.js | 5 +++- nyc.config.js | 4 ++-- package.json | 9 +++++--- tsconfig.json | 21 +++++++++++++++++ web/webpack.config.js | 9 +++++--- yarn.lock | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 107 insertions(+), 10 deletions(-) diff --git a/.mocharc.js b/.mocharc.js index 4354b8f..2200690 100644 --- a/.mocharc.js +++ b/.mocharc.js @@ -19,5 +19,5 @@ */ module.exports = { - require: ['@babel/register', 'chai/register-assert'], + require: ['./babel-register.js', 'chai/register-assert'], }; diff --git a/babel-register.js b/babel-register.js new file mode 100644 index 0000000..929499a --- /dev/null +++ b/babel-register.js @@ -0,0 +1,3 @@ +const register = require('@babel/register').default; + +register({ extensions: ['.ts', '.js'] }); diff --git a/babel.config.js b/babel.config.js index 92f6ba4..dcd45ea 100644 --- a/babel.config.js +++ b/babel.config.js @@ -55,6 +55,9 @@ module.exports = api => { ...(DEV ? [['module-resolver', resolverOptions]] : []), ...(TEST ? ['istanbul'] : []), ], - presets: [['@babel/env', envOptions]], + presets: [ + ['@babel/env', envOptions], + '@babel/preset-typescript', + ], }; }; diff --git a/nyc.config.js b/nyc.config.js index e43ea32..08d36cf 100644 --- a/nyc.config.js +++ b/nyc.config.js @@ -20,8 +20,8 @@ module.exports = { all: true, - include: ['packages/*/src/**/*.js'], + include: ['packages/*/src/**/*.[jt]s'], instrument: false, sourceMap: false, - require: ['@babel/register'], + require: ['./babel-register.js'], }; diff --git a/package.json b/package.json index 6c493d7..07e02ba 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ }, "scripts": { "build": "yarn run build:cjs && yarn run build:esm && yarn run build:misc", - "build:babel": "lerna exec --parallel -- babel --root-mode upward", + "build:babel": "lerna exec --parallel -- babel --extensions '.js,.ts' --root-mode upward", "build:cjs": "cross-env BABEL_ENV=cjs yarn build:babel -d lib src", "build:esm": "cross-env BABEL_ENV=esm yarn build:babel -d esm src", "build:misc": "lerna exec -- cp ../../LICENSE ../../NOTICE .", @@ -25,8 +25,9 @@ "prepare": "lerna run prepare", "prepublishOnly": "yarn run build", "start": "yarn run web:server", - "test": "cross-env BABEL_ENV=test nyc mocha packages/*/test/**/*.js", - "validate": "cross-env BABEL_ENV=test mocha test/**/*.js", + "test": "cross-env BABEL_ENV=test nyc mocha packages/*/test/**/*.[jt]s", + "typecheck": "tsc --noEmit || true", + "validate": "cross-env BABEL_ENV=test mocha test/**/*.[jt]s", "web:build": "webpack --config=web/webpack.config.js --mode development", "web:server": "webpack-dev-server --config=web/webpack.config.js --hot --mode development" }, @@ -40,6 +41,7 @@ "@babel/core": "^7.8.7", "@babel/plugin-transform-runtime": "^7.8.3", "@babel/preset-env": "^7.8.7", + "@babel/preset-typescript": "^7.9.0", "@babel/register": "^7.8.6", "ajv": "^6.11.0", "babel-eslint": "^10.0.3", @@ -68,6 +70,7 @@ "prettier": "^1.19.1", "resolve": "^1.15.0", "rimraf": "^3.0.0", + "typescript": "^3.8.3", "web-annotation-tests": "https://github.com/w3c/web-annotation-tests", "webpack": "^4.41.5", "webpack-cli": "^3.3.10", diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..2e42fbc --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "noImplicitAny": true, + "target": "ES2017", + "lib": [ + "ES2020", + "DOM", + "DOM.Iterable" + ], + "moduleResolution": "Node", + "allowSyntheticDefaultImports": true, + "typeRoots": [ + "./node_modules/@types", + "./@types" + ] + }, + "files": [ + "packages/dom/src/index.ts", + "packages/selector/src/index.ts", + ] +} diff --git a/web/webpack.config.js b/web/webpack.config.js index 7876d94..8ae81e8 100644 --- a/web/webpack.config.js +++ b/web/webpack.config.js @@ -31,19 +31,22 @@ module.exports = { test: [ './test/index.html', 'chai/register-assert', - 'mocha-loader!multi-entry-loader?include=./packages/*/test/**/*.js!', + 'mocha-loader!multi-entry-loader?include=./packages/*/test/**/*.[jt]s!', ], }, + resolve: { + extensions: ['.ts', '.js'], + }, devtool: 'inline-source-map', module: { rules: [ { - test: /\.js$/, + test: /\.[jt]s$/, exclude: /node_modules/, use: 'babel-loader', }, { - exclude: /\.js$/, + exclude: /\.[jt]s$/, use: [ { loader: 'file-loader', diff --git a/yarn.lock b/yarn.lock index 1d7ce46..722c24d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -148,6 +148,18 @@ levenary "^1.1.1" semver "^5.5.0" +"@babel/helper-create-class-features-plugin@^7.8.3": + version "7.9.5" + resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.9.5.tgz#79753d44017806b481017f24b02fd4113c7106ea" + integrity sha512-IipaxGaQmW4TfWoXdqjY0TzoXQ1HRS0kPpEgvjosb3u7Uedcq297xFqDQiCcQtRRwzIMif+N1MLVI8C5a4/PAA== + dependencies: + "@babel/helper-function-name" "^7.9.5" + "@babel/helper-member-expression-to-functions" "^7.8.3" + "@babel/helper-optimise-call-expression" "^7.8.3" + "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-replace-supers" "^7.8.6" + "@babel/helper-split-export-declaration" "^7.8.3" + "@babel/helper-create-regexp-features-plugin@^7.8.3": version "7.8.3" resolved "https://registry.yarnpkg.com/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.8.3.tgz#c774268c95ec07ee92476a3862b75cc2839beb79" @@ -191,6 +203,15 @@ "@babel/template" "^7.8.3" "@babel/types" "^7.8.3" +"@babel/helper-function-name@^7.9.5": + version "7.9.5" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.9.5.tgz#2b53820d35275120e1874a82e5aabe1376920a5c" + integrity sha512-JVcQZeXM59Cd1qanDUxv9fgJpt3NeKUaqBqUEvfmQ+BCOKq2xUgaWZW2hr0dkbyJgezYuplEoh5knmrnS68efw== + dependencies: + "@babel/helper-get-function-arity" "^7.8.3" + "@babel/template" "^7.8.3" + "@babel/types" "^7.9.5" + "@babel/helper-get-function-arity@^7.7.4": version "7.7.4" resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.7.4.tgz#cb46348d2f8808e632f0ab048172130e636005f0" @@ -315,6 +336,11 @@ dependencies: "@babel/types" "^7.8.3" +"@babel/helper-validator-identifier@^7.9.5": + version "7.9.5" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.5.tgz#90977a8e6fbf6b431a7dc31752eee233bf052d80" + integrity sha512-/8arLKUFq882w4tWGj9JYzRpAlZgiWUJ+dtteNTDqrRBz9Iguck9Rn3ykuBDoUwh2TO4tSAJlrxDUOXWklJe4g== + "@babel/helper-wrap-function@^7.8.3": version "7.8.3" resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.8.3.tgz#9dbdb2bb55ef14aaa01fe8c99b629bd5352d8610" @@ -497,6 +523,13 @@ dependencies: "@babel/helper-plugin-utils" "^7.8.3" +"@babel/plugin-syntax-typescript@^7.8.3": + version "7.8.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.8.3.tgz#c1f659dda97711a569cef75275f7e15dcaa6cabc" + integrity sha512-GO1MQ/SGGGoiEXY0e0bSpHimJvxqB7lktLLIq2pv8xG7WZ8IMEle74jIe1FhprHBWjwjZtXHkycDLZXIWM5Wfg== + dependencies: + "@babel/helper-plugin-utils" "^7.8.3" + "@babel/plugin-transform-arrow-functions@^7.8.3": version "7.8.3" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.8.3.tgz#82776c2ed0cd9e1a49956daeb896024c9473b8b6" @@ -744,6 +777,15 @@ dependencies: "@babel/helper-plugin-utils" "^7.8.3" +"@babel/plugin-transform-typescript@^7.9.0": + version "7.9.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.9.4.tgz#4bb4dde4f10bbf2d787fce9707fb09b483e33359" + integrity sha512-yeWeUkKx2auDbSxRe8MusAG+n4m9BFY/v+lPjmQDgOFX5qnySkUY5oXzkp6FwPdsYqnKay6lorXYdC0n3bZO7w== + dependencies: + "@babel/helper-create-class-features-plugin" "^7.8.3" + "@babel/helper-plugin-utils" "^7.8.3" + "@babel/plugin-syntax-typescript" "^7.8.3" + "@babel/plugin-transform-unicode-regex@^7.8.3": version "7.8.3" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.8.3.tgz#0cef36e3ba73e5c57273effb182f46b91a1ecaad" @@ -815,6 +857,14 @@ levenary "^1.1.1" semver "^5.5.0" +"@babel/preset-typescript@^7.9.0": + version "7.9.0" + resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.9.0.tgz#87705a72b1f0d59df21c179f7c3d2ef4b16ce192" + integrity sha512-S4cueFnGrIbvYJgwsVFKdvOmpiL0XGw9MFW9D0vgRys5g36PBhZRL8NX8Gr2akz8XRtzq6HuDXPD/1nniagNUg== + dependencies: + "@babel/helper-plugin-utils" "^7.8.3" + "@babel/plugin-transform-typescript" "^7.9.0" + "@babel/register@^7.8.6": version "7.8.6" resolved "https://registry.yarnpkg.com/@babel/register/-/register-7.8.6.tgz#a1066aa6168a73a70c35ef28cc5865ccc087ea69" @@ -956,6 +1006,15 @@ lodash "^4.17.13" to-fast-properties "^2.0.0" +"@babel/types@^7.9.5": + version "7.9.5" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.9.5.tgz#89231f82915a8a566a703b3b20133f73da6b9444" + integrity sha512-XjnvNqenk818r5zMaba+sLQjnbda31UfUURv3ei0qPQw4u+j2jMyJ5b11y8ZHYTRSI3NnInQkkkRT4fLqqPdHg== + dependencies: + "@babel/helper-validator-identifier" "^7.9.5" + lodash "^4.17.13" + to-fast-properties "^2.0.0" + "@evocateur/libnpmaccess@^3.1.2": version "3.1.2" resolved "https://registry.yarnpkg.com/@evocateur/libnpmaccess/-/libnpmaccess-3.1.2.tgz#ecf7f6ce6b004e9f942b098d92200be4a4b1c845" @@ -9698,6 +9757,11 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= +typescript@^3.8.3: + version "3.8.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061" + integrity sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w== + uglify-js@^3.1.4: version "3.6.0" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.6.0.tgz#704681345c53a8b2079fb6cec294b05ead242ff5"
