-
Notifications
You must be signed in to change notification settings - Fork 318
Conversation
@timneutkens Is there a way for the plugin to check for next.js v6? Because the upgrade error should be updated and thrown for versions below 6. |
@@ -35,23 +35,15 @@ module.exports = (nextConfig = {}) => { | |||
}) | |||
} | |||
|
|||
if (!defaultLoaders.babel.options.babelrc) { | |||
defaultLoaders.babel.options.presets.unshift("@babel/preset-typescript") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets have the user explicitly configure this in .babelrc, regardless of if they have one or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's very user-friendly … IMO it kind of defeats the purpose having a plugin when you have to
- install the plugin
- install
@babel/preset-typescript
- add the plugin to
next.config.js
- add a
.babelrc
) | ||
} | ||
] | ||
use: defaultLoaders.babel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets keep this an array, otherwise I guess you could use loader
as a key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we do it like this in Next's webpack config, so nevermind.
@@ -5,9 +5,10 @@ | |||
"license": "MIT", | |||
"repository": "zeit/next-plugins", | |||
"dependencies": { | |||
"ts-loader": "3.3.1" | |||
"@babel/preset-typescript": "^7.0.0-beta.46" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets have users install this too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I have a better idea to be backwards compatible in the future.
Lets create @zeit/next-typescript/babel
(babel.js
) which is a babel preset adding @babel/preset-typescript
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what adding another preset would solve? It would just include @babel/preset-typescript
, right?
@timneutkens Thanks for looking at this. Maybe it's not such a good idea to replace the existing plugin but probably it would be better to create a dedicated plugin since for some cases you'd still want to use Also, I think using the "new" plugin should be as easy as the current one, so I'm strongly against telling users to add a dependency and I can change this PR to add a new official |
So the workflow I'd like to do is:
The reason for this is consistency between having a .babelrc and not having a .babelrc, since it's custom babel behaviour it makes sense to add a |
Regarding
I don't think the caveats outweigh the gained performance. So I want to make next-typescript use the babel way, and if that's not enough for specific projects someone from the community could fork the older version and maintain it. Also this new version of next-typescript will be released as a major version (since the older one doesn't break in next 6 anyway). |
Implemented everything mentioned above here: #171 |
Since next.js v6 uses Babel 7, TypeScript can be compiled without
ts-loader
. Compilation should be considerably faster this way, especially in larger apps. Type checking still works withfork-ts-checker-webpack-plugin
.I've tested that this works but I'm not sure adding
@babel/preset-typescript
todefaultLoaders.babel.options.presets
is safe to do. But it's the most convenient way without requiring users to add a custom.babelrc
file.This is a breaking change and should be a major bump (or rather minor to
0.2.0
), since it depends on next@6 and removestypescriptLoaderOptions
.