From 3b0daf7e104a28806ccefbcac0550f43890d4827 Mon Sep 17 00:00:00 2001 From: Peter Oesteritz Date: Thu, 6 Feb 2020 10:35:40 +0100 Subject: [PATCH 1/5] switch from ts-loader to babel-loader --- docs/testing.md | 3 +-- docs/typescript.md | 24 ++++------------------- lib/install/config/webpack/environment.js | 1 + lib/install/loaders/typescript.js | 11 ----------- lib/install/typescript.rb | 22 ++++++++++----------- lib/webpacker/compiler.rb | 5 ++--- package/rules/index.js | 4 +++- package/rules/typescript.js | 21 ++++++++++++++++++++ 8 files changed, 43 insertions(+), 48 deletions(-) delete mode 100644 lib/install/loaders/typescript.js create mode 100644 package/rules/typescript.js diff --git a/docs/testing.md b/docs/testing.md index 49b6db97e..e77984050 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -10,8 +10,7 @@ Webpacker does not setup `Karma` by default, so you've to manually install it al "test": "NODE_ENV=test karma start" }, "dependencies": { - "typescript": "^2.5.2", - "ts-loader": "^2.3.7" + "typescript": "^2.5.2" }, "devDependencies": { "karma": "^1.7.1", diff --git a/docs/typescript.md b/docs/typescript.md index 04769c50f..9eda231ab 100644 --- a/docs/typescript.md +++ b/docs/typescript.md @@ -21,35 +21,19 @@ bundle exec rails webpacker:install:typescript ``` 2. Rename generated `hello_vue.js` to `hello_vue.ts`. -3. Add the webpack plug-n-play plugin to your yarn packages with `yarn add pnp-webpack-plugin`. -4. Change the generated `config/webpack/loaders/typescript.js` from +3. Change the generated `babel.config.js` from ```js -module.exports = { - test: /\.tsx?(\.erb)?$/, - use: [{ - loader: 'ts-loader' - }] -} +["@babel/preset-typescript", { "allExtensions": true, "isTSX": true }] ``` to ```js -const PnpWebpackPlugin = require('pnp-webpack-plugin'); - -module.exports = { - test: /\.tsx?(\.erb)?$/, - use: [{ - loader: 'ts-loader', - options: PnpWebpackPlugin.tsLoaderOptions({ - appendTsSuffixTo: [/\.vue$/] - }) - }] -} +["babel-preset-typescript-vue", { "allExtensions": true, "isTSX": true }] ``` -and now you can use `