-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added TypeScript upgrade docs for Webpacker 5.1 #2541
Added TypeScript upgrade docs for Webpacker 5.1 #2541
Conversation
A possible rake task could look like this: say "Remove old packages"
run "yarn remove ts-loader"
say "Add new packages"
run "yarn add @babel/preset-typescript babel-preset-typescript-vue -D"
say "Remove old configuration files"
remove_file "config/webpack/loaders/typescript.js"
say "Remove old webpack configurations"
gsub_file Rails.root.join("config/webpack/environment.js").to_s, /const typescript = require\('\.\/loaders\/typescript'\)\n/, ""
gsub_file Rails.root.join("config/webpack/environment.js").to_s, /environment\.loaders\.prepend\('typescript', typescript\)\n/, ""
say "Adding TypeScript preset to babel.config.js"
insert_into_file Rails.root.join("babel.config.js").to_s,
",\n ['@babel/preset-typescript', { 'allExtensions': true, 'isTSX': true }]",
before: /\s*\].filter\(Boolean\),\n\s*plugins: \[/ But we may have to make Additionally, should we add a warning to Rails' console if we find old configurations while running version 5.1? |
I was able to migrate to 5.1 using these instructions, so this works fine. However, and I'm not sure where to put this (here or #2449), asset compilation in a production environment now fails. This is because the instructions tell me to install Example stacktrace for `@babel/preset-typescript`
|
Oh, yes, then this should be installed as a normal dependency – all other loaders and presets aren't |
Thanks @gopeter - Please could you link this in changelog under 5.1 release? |
Like so?
|
Thank you @gopeter for the work! Followed the instruction and it worked like a charm. One small question. Do we always need
|
Hmm, maybe just a line beneath,
Also, |
Ok, both points are done |
Great, thanks :) One last thing, can we use additional packages for vue if defined in package.json, like React? Please see this: webpacker/lib/install/typescript.rb Line 12 in 66e5c1b
|
It doesn't have to be though, only if it makes sense (since we are doing it for React) |
Hmmm but what happens if someone runs For React, we're just adding the appropriate types, which can be done by the user too. But since If we want to do this, we would need to add
to What do you think about this? |
I see, makes sense. Let's leave it then, maybe we can improve it later. |
Merged, thanks for working on it 🙏 |
OK, great! I've created #2543 if you want to have a look. |
https://build.opensuse.org/request/show/865216 by user coolo + dimstar_suse updated to version 5.2.1 see installed CHANGELOG.md ## [[5.2.1]](rails/webpacker@v5.2.0...5.2.1) - 2020-08-17 - Revert [#1311](rails/webpacker#1311). ## [[5.2.0]](rails/webpacker@v5.1.1...5.2.0) - 2020-08-16 - Bump dependencies and fixes. See [diff](rails/webpacker@v5.1.1...5-x-stable) for changes. - updated to version 5.1.1 see installed CHANGELOG.md ## [[5.1.1]](rails/webpacker@v5.1.0...v5.1.1) - 2020-04-20 - Update [TypeScript documentation](https://github.com/rails/webpacker/blob/master/docs/typescript.md) and installer to use babel-loader for typescript.[(#2541](rails/webpacker#2541) ## [[5.1.0]](ht
As mentioned in #2449, we need some documentation to upgrade the TypeScript configuration for users who have updated to
webpacker >= 5.1
I'll have a look how we can implement this as a
rake
task too.