From e27d421f8a6a1d45d115d937279c9d6ed67a01a3 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Sat, 17 Mar 2018 15:11:52 +0200 Subject: [PATCH] chore: migrate to ts-loader --- demo/webpack.config.ts | 10 ++-- e2e/plugins/cy-ts-preprocessor.js | 4 +- package.json | 3 +- src/components/Schema/Schema.tsx | 2 +- tsconfig.json | 6 +-- webpack.config.ts | 17 ++++-- yarn.lock | 89 +++++++++++++++++++++---------- 7 files changed, 83 insertions(+), 48 deletions(-) diff --git a/demo/webpack.config.ts b/demo/webpack.config.ts index 8d6b3a9d..36597501 100644 --- a/demo/webpack.config.ts +++ b/demo/webpack.config.ts @@ -28,7 +28,7 @@ export default { resolve: { extensions: ['.ts', '.tsx', '.js', '.json'], }, - + node: { fs: 'empty', }, @@ -42,7 +42,7 @@ export default { use: [ 'react-hot-loader/webpack', { - loader: 'awesome-typescript-loader', + loader: 'ts-loader', options: { module: 'es2015', }, @@ -63,11 +63,11 @@ export default { { test: /node_modules\/(swagger2openapi|reftools)\/.*\.js$/, use: { - loader: 'awesome-typescript-loader', + loader: 'ts-loader', + transpileOnly: true, + instance: 'ts2js-transpiler-only', options: { - transpileOnly: true, allowJs: true, - instance: 'ts2js-transpiler-only', }, }, }, diff --git a/e2e/plugins/cy-ts-preprocessor.js b/e2e/plugins/cy-ts-preprocessor.js index 87c12fff..81187415 100644 --- a/e2e/plugins/cy-ts-preprocessor.js +++ b/e2e/plugins/cy-ts-preprocessor.js @@ -11,9 +11,9 @@ const webpackOptions = { exclude: [/node_modules/], use: [ { - loader: 'awesome-typescript-loader', + loader: 'ts-loader', options: { - configFileName: 'e2e/tsconfig.json', + configFile: 'e2e/tsconfig.json', }, }, ], diff --git a/package.json b/package.json index 1631466c..8b8ae388 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,6 @@ "@types/webpack": "^3.0.5", "@types/webpack-env": "^1.13.0", "@types/yargs": "^11.0.0", - "awesome-typescript-loader": "^3.2.2", "babel-loader": "8.0.0-beta.2", "beautify-benchmark": "^0.2.4", "conventional-changelog-cli": "^1.3.5", @@ -57,6 +56,7 @@ "enzyme": "^3.1.1", "enzyme-adapter-react-16": "^1.0.4", "enzyme-to-json": "^3.2.2", + "fork-ts-checker-webpack-plugin": "^0.4.1", "html-webpack-plugin": "^2.30.1", "jest": "^22.1.4", "lodash": "^4.17.4", @@ -72,6 +72,7 @@ "source-map-loader": "^0.2.1", "style-loader": "^0.20.1", "ts-jest": "^22.0.1", + "ts-loader": "3", "ts-node": "^4.1.0", "tslint": "^5.7.0", "tslint-react": "^3.4.0", diff --git a/src/components/Schema/Schema.tsx b/src/components/Schema/Schema.tsx index 7980f062..1be8d4cb 100644 --- a/src/components/Schema/Schema.tsx +++ b/src/components/Schema/Schema.tsx @@ -4,7 +4,7 @@ import * as React from 'react'; import { RecursiveLabel, TypeName, TypeTitle } from '../../common-elements/fields'; import { FieldDetails } from '../Fields/FieldDetails'; -import { SchemaModel, FieldModel } from '../../services/models'; +import { FieldModel, SchemaModel } from '../../services/models'; import { ArraySchema } from './ArraySchema'; import { ObjectSchema } from './ObjectSchema'; diff --git a/tsconfig.json b/tsconfig.json index e5377f17..3994a99c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -36,9 +36,5 @@ "./src/index.ts", "./src/standalone.tsx", "demo/*.tsx" - ], - "awesomeTypescriptLoaderOptions": { - "resolveGlobs": true, - "useWebpackText": true - } + ] } diff --git a/webpack.config.ts b/webpack.config.ts index 76641c24..69e8da91 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -1,5 +1,7 @@ import * as webpack from 'webpack'; import * as HtmlWebpackPlugin from 'html-webpack-plugin'; +import * as ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'; +import * as path from 'path'; const nodeExternals = require('webpack-node-externals')({ // bundle in moudules that need transpiling + non-js (e.g. css) @@ -82,9 +84,11 @@ export default env => { { test: /\.tsx?$/, use: { - loader: 'awesome-typescript-loader', + loader: 'ts-loader', options: { - module: env.perf ? 'esnext' : 'es2015', + compilerOptions: { + module: env.perf ? 'esnext' : 'es2015', + }, }, }, exclude: ['node_modules'], @@ -92,11 +96,13 @@ export default env => { { test: /node_modules\/(swagger2openapi|reftools)\/.*\.js$/, use: { - loader: 'awesome-typescript-loader', + loader: 'ts-loader', options: { - transpileOnly: true, - allowJs: true, instance: 'ts2js-transpiler-only', + transpileOnly: true, + compilerOptions: { + allowJs: true, + }, }, }, }, @@ -121,6 +127,7 @@ export default env => { __REDOC_DEV__: env.prod ? 'false' : 'true', }), new webpack.NamedModulesPlugin(), + new ForkTsCheckerWebpackPlugin(), ], }; diff --git a/yarn.lock b/yarn.lock index 6d87f584..48cdcadf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -678,18 +678,6 @@ autoprefixer@^6.3.1: postcss "^5.2.16" postcss-value-parser "^3.2.3" -awesome-typescript-loader@^3.2.2: - version "3.5.0" - resolved "https://registry.yarnpkg.com/awesome-typescript-loader/-/awesome-typescript-loader-3.5.0.tgz#4d4d10cba7a04ed433dfa0334250846fb11a1a5a" - dependencies: - chalk "^2.3.1" - enhanced-resolve "3.3.0" - loader-utils "^1.1.0" - lodash "^4.17.4" - micromatch "^3.0.3" - mkdirp "^0.5.1" - source-map-support "^0.5.3" - aws-sign2@~0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" @@ -1690,7 +1678,7 @@ cheerio@^1.0.0-rc.2: lodash "^4.15.0" parse5 "^3.0.1" -chokidar@^1.6.0: +chokidar@^1.6.0, chokidar@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468" dependencies: @@ -2751,16 +2739,7 @@ encoding@^0.1.11: dependencies: iconv-lite "~0.4.13" -enhanced-resolve@3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-3.3.0.tgz#950964ecc7f0332a42321b673b38dc8ff15535b3" - dependencies: - graceful-fs "^4.1.2" - memory-fs "^0.4.0" - object-assign "^4.0.1" - tapable "^0.2.5" - -enhanced-resolve@^3.4.0: +enhanced-resolve@^3.0.0, enhanced-resolve@^3.4.0: version "3.4.1" resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-3.4.1.tgz#0421e339fd71419b3da13d129b3979040230476e" dependencies: @@ -3399,6 +3378,22 @@ forever-agent@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" +fork-ts-checker-webpack-plugin@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-0.4.1.tgz#718801621c50c7f20de9c8e6a68a2db228a4081f" + dependencies: + babel-code-frame "^6.22.0" + chalk "^1.1.3" + chokidar "^1.7.0" + lodash.endswith "^4.2.1" + lodash.isfunction "^3.0.8" + lodash.isstring "^4.0.1" + lodash.startswith "^4.2.1" + minimatch "^3.0.4" + resolve "^1.5.0" + tapable "^1.0.0" + vue-parser "^1.1.5" + form-data@~2.1.1: version "2.1.4" resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.4.tgz#33c183acf193276ecaa98143a69e94bfee1750d1" @@ -5058,10 +5053,22 @@ lodash.clonedeep@4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" +lodash.endswith@^4.2.1: + version "4.2.1" + resolved "https://registry.yarnpkg.com/lodash.endswith/-/lodash.endswith-4.2.1.tgz#fed59ac1738ed3e236edd7064ec456448b37bc09" + lodash.flattendeep@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2" +lodash.isfunction@^3.0.8: + version "3.0.9" + resolved "https://registry.yarnpkg.com/lodash.isfunction/-/lodash.isfunction-3.0.9.tgz#06de25df4db327ac931981d1bdb067e5af68d051" + +lodash.isstring@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/lodash.isstring/-/lodash.isstring-4.0.1.tgz#d527dfb5456eca7cc9bb95d5daeaf88ba54a5451" + lodash.memoize@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" @@ -5078,6 +5085,10 @@ lodash.sortby@^4.7.0: version "4.7.0" resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" +lodash.startswith@^4.2.1: + version "4.2.1" + resolved "https://registry.yarnpkg.com/lodash.startswith/-/lodash.startswith-4.2.1.tgz#c598c4adce188a27e53145731cdc6c0e7177600c" + lodash.template@^4.0.2: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.4.0.tgz#e73a0385c8355591746e020b99679c690e68fba0" @@ -5302,7 +5313,7 @@ micromatch@^2.1.5, micromatch@^2.3.11: parse-glob "^3.0.4" regex-cache "^0.4.2" -micromatch@^3.0.3, micromatch@^3.1.4: +micromatch@^3.1.4: version "3.1.9" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.9.tgz#15dc93175ae39e52e93087847096effc73efcf89" dependencies: @@ -5929,7 +5940,7 @@ parse5@4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/parse5/-/parse5-4.0.0.tgz#6d78656e3da8d78b4ec0b906f7c08ef1dfe3f608" -parse5@^3.0.1: +parse5@^3.0.1, parse5@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/parse5/-/parse5-3.0.3.tgz#042f792ffdd36851551cf4e9e066b3874ab45b5c" dependencies: @@ -6951,7 +6962,7 @@ resolve@1.1.7: version "1.1.7" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" -resolve@^1.1.6, resolve@^1.1.7, resolve@^1.3.2: +resolve@^1.1.6, resolve@^1.1.7, resolve@^1.3.2, resolve@^1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.5.0.tgz#1f09acce796c9a762579f31b2c1cc4c3cddf9f36" dependencies: @@ -7072,7 +7083,7 @@ selfsigned@^1.9.1: dependencies: node-forge "0.7.1" -"semver@2 || 3 || 4 || 5", semver@^5.3.0, semver@^5.4.1, semver@^5.5.0: +"semver@2 || 3 || 4 || 5", semver@^5.0.1, semver@^5.3.0, semver@^5.4.1, semver@^5.5.0: version "5.5.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab" @@ -7356,7 +7367,7 @@ source-map-support@^0.4.15: dependencies: source-map "^0.5.6" -source-map-support@^0.5.0, source-map-support@^0.5.3: +source-map-support@^0.5.0: version "0.5.3" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.3.tgz#2b3d5fff298cfa4d1afd7d4352d569e9a0158e76" dependencies: @@ -7697,10 +7708,14 @@ table@4.0.2: slice-ansi "1.0.0" string-width "^2.1.1" -tapable@^0.2.5, tapable@^0.2.7: +tapable@^0.2.7: version "0.2.8" resolved "https://registry.yarnpkg.com/tapable/-/tapable-0.2.8.tgz#99372a5c999bf2df160afc0d74bed4f47948cd22" +tapable@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/tapable/-/tapable-1.0.0.tgz#cbb639d9002eed9c6b5975eb20598d7936f1f9f2" + tar-pack@^3.4.0: version "3.4.1" resolved "https://registry.yarnpkg.com/tar-pack/-/tar-pack-3.4.1.tgz#e1dbc03a9b9d3ba07e896ad027317eb679a10a1f" @@ -7880,6 +7895,16 @@ ts-jest@^22.0.1: pkg-dir "^2.0.0" yargs "^11.0.0" +ts-loader@3: + version "3.5.0" + resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-3.5.0.tgz#151d004dcddb4cf8e381a3bf9d6b74c2d957a9c0" + dependencies: + chalk "^2.3.0" + enhanced-resolve "^3.0.0" + loader-utils "^1.0.2" + micromatch "^3.1.4" + semver "^5.0.1" + ts-node@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-4.1.0.tgz#36d9529c7b90bb993306c408cd07f7743de20712" @@ -8178,6 +8203,12 @@ vm-browserify@0.0.4: dependencies: indexof "0.0.1" +vue-parser@^1.1.5: + version "1.1.6" + resolved "https://registry.yarnpkg.com/vue-parser/-/vue-parser-1.1.6.tgz#3063c8431795664ebe429c23b5506899706e6355" + dependencies: + parse5 "^3.0.3" + w3c-hr-time@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/w3c-hr-time/-/w3c-hr-time-1.0.1.tgz#82ac2bff63d950ea9e3189a58a65625fedf19045"