-
Notifications
You must be signed in to change notification settings - Fork 2
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
Support ts file and Make Its usage similar as official next-plugins #5
Conversation
…atibility issue with multi plugin composing scenario
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.
That's really great! I was thinking about it myself, but you know how this usually works :) There's few issues to fix, but do you mind if I'll do it myself?
@@ -23,7 +23,7 @@ module.exports = (awesomeTypescriptOptions = {}, nextConfig = {}) => { | |||
} | |||
|
|||
const { dir, defaultLoaders, dev, isServer } = options; | |||
const { useCheckerPlugin, loaderOptions } = awesomeTypescriptOptions; | |||
const { useCheckerPlugin, loaderOptions } = nextConfig.awesomeTypescriptOptions; |
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.
This will fail if awesomeTypescriptOptions
is null or undefined, I guess we can write it as const { useCheckerPlugin, loaderOptions } = nextConfig.awesomeTypescriptOptions || {};
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 think you are right. If a user doesn't pass any arguments then my code will fail.
@@ -35,7 +35,7 @@ module.exports = (awesomeTypescriptOptions = {}, nextConfig = {}) => { | |||
|
|||
if (dev && !isServer) { | |||
config.module.rules.push({ | |||
test: /\.tsx?$/, | |||
test: /\.(ts|tsx)?$/, |
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.
What's the point of this change, to be more aligned with next-plugins
codebase? I mean I don't mind, just want to clarify.
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.
because I had an error with myFile.ts file. I usually use .ts file If It's not a react component. I may be wrong, if there is another way to use .ts file then let me know.
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.
uhm, that's strange, because tsx?
means ts
or tsx
which is exactly (ts|tsx)
. I'll check it
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.
Thanks! It didn't work with my code, but maybe I was doing wrong. webpack is still complicated to me...
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.
Ok, I've checked it, and tsx?
is working fine on my side for .ts
files. Feel free to raise an issue if the error persists
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 tested again by making ts file and import from another file... and It worked! hm... I thought to make stateless functional component with .ts file should work and It didn't... It should have been .tsx because It looks like just an arrow function, but It has html and other tsx syntax. sorry for this stupid mistake. But If It worked from by not making stupid mistake, I wouldn't even start looking it more about this next-plugins hahaha
useCheckerPlugin: true, | ||
loaderOptions: { | ||
transpileOnly: false, | ||
}, | ||
}; | ||
|
||
module.exports = withAwesomeTypescript(options); | ||
module.exports = withAwesomeTypescript(awesomeTypescriptOptions); |
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.
It should be module.exports = withAwesomeTypescript({ awesomeTypescriptOptions });
``` | ||
|
||
Optionally you can add your custom Next.js configuration as second parameter | ||
Optionally you can add your custom Next.js configuration as a parameter |
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.
Maybe we'll merge last two cases into one?
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.
yes, If you want!
This is one of my very first PR, so If there is any problem, please let me know. Think me as a junior programmer :D Also I made a PR to next-plugins about the document. just in case. (vercel/next-plugins#156) |
@lonyele that's a pretty good PR, even for the first one! I fixed the issues (I hope you don't mind) and merged the branch. And, for the future, it's better to create a feature branch for each PR, it's easier to work with. |
Ok, I've released |
Wow! Thanks for your feedback and merging work. I would definitely make feature branch and PR next time. still, I don't know how this open source workflow works. on top of that, I use git only for myself... It is my first time sharing my code with others. anyway, thanks a lot~ |
Hi, I found that in a multi plugin composing case, Its usage is not same as official next-plugin thus I made these changes. If you want it as it is, still documentation is needed for its usage because It is not same as other official next-plugins)
Before
After