-
Notifications
You must be signed in to change notification settings - Fork 279
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
Document tsconfig File for Plop Usage in TS #192
Comments
Do I need to pass some typescript loader here? |
Ok, if node can't load ES6 modules, maybe I can use require syntax?
Nope, I can't:
|
What am I missing here? Does Plop support typescript? |
Renamed to |
@cspotcode @crutchcorn Any ideas here? This typescript stuff is kind of your baby 😉 |
@Vanuan tl;dr install @amwmedia this is a more general Liftoff issue when using any sort of loader, not just TypeScript. (babel, coffeescript, etc) Looks like Liftoff attempts to install any of the loaders declared in The plop docs can be updated to mention that TypeScript requires installing |
Thanks for taking a look at this. It looks like we do need to bolster documentation in this area a bit. 👍 |
Seeing as everybody isn't using TypeScript, perhaps a |
Hey @cspotcode, I am running into the same issue using create-react-app TypeScript boilerplate. Any advice? I believe that boilerplate already uses all required dependencies. |
Just a note: typesript.json should include
|
if you used ts, you may need separate configuration tsconfig.json
|
You can also specify a ts-node sub-object within your root tsconfig file.
This allows your primary ts config to contain a *different* set of
compilerOptions for ts-node.
…On Tue, Dec 15, 2020, 3:27 AM Statfine ***@***.***> wrote:
if you used ts, you may need separate configuration tsconfig.json
"generate": "cross-env TS_NODE_PROJECT='./internals/ts-node.tsconfig.json' plop --plopfile ./internals/plopfile.ts"
ts-node.tsconfig.json
{
"compilerOptions": {
"esModuleInterop": true,
"module": "commonjs",
"moduleResolution": "node",
"noEmit": true,
"allowSyntheticDefaultImports": true
}
}
``
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#192 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAC35OAWDN6JYJPOS5ZERWLSU4MX5ANCNFSM4J4C7REQ>
.
|
@cspotcode which property can do it in my root tsconfig file or can you give an example |
https://github.com/TypeStrong/ts-node#options-via-tsconfigjson {
// a tsconfig file with ts-node options looks like this
"compilerOptions": {
// ... options here
},
"ts-node": {
// ts-node options here
"transpileOnly": true,
"compiler": "ttypescript",
// ts-node-specific overrides for compilerOptions
// any compilerOptions specified here will override the values specified above, *only* when running in ts-node
"compilerOptions": {
}
} |
I am facing the same problem. I've created a simple
Here is my
And this is my
Please, could it be possible to have a simple example of the plop.js library setup with typescript? |
Plop uses ts-node so you are missing |
Could we re-open this issue until a best practice approach to using typescript and plop is documented ? |
Fair enough @ivanoats. Changed the title. I'm working on some pretty major stabilization efforts for Plop currently (in prep for larger revamp efforts), but PRs are welcomed and will 100% be documented :) @FDiskas maybe you wanna tackle this one? If you update the README.md file, it'll auto update to the website when we deploy |
Awesome, thank you. I am happy to collaborate on a PR. I haven't figured it out myself but happy to test and document. |
@ivanoats if you'd be willing to make a PR that'd be awesome I've added an example usage of TS here: https://github.com/plopjs/plop/blob/master/example/typescript/tsconfig.json We require these values to be set for TSConfig and the TypeScript We also may want to suggest users (despite not being required) use the https://github.com/plopjs/plop/blob/master/example/typescript/plopfile.ts#L1-L2 This may silence other errors and verify/enforce that commonjs is set as the output. |
@crutchcorn I created a small PR regarding this. Updated typescript example and added a note in the readme file. I'm a not native speaker so take a look at grammar also. |
I'm running into this issue as well. I'm trying to apply some of the solutions mentioned on this PR, but unfortunately none works. ( What's the workaround to have Thanks |
@csantos-nydig check the example #290 |
I followed all instructions here and also what is in the example FDiskas linked but I keep getting the same error no matter what
☝️ this error keeps being thrown no matter what 🤷 Either way, I just wanted to say that this lib is great regardless so thanks for maintaining it |
@danielfigueiredo sounds like you've got Check out https://typestrong.org/ts-node/docs/module-type-overrides |
This error is mentioned in ts-node's docs, and I just made a small update to mention this specific situation: config files that you want to execute as CJS within an ESM project: https://typestrong.org/ts-node/docs/troubleshooting/#err_unknown_file_extension Note that, if you really do need your config to run as ESM, then you're stuck using node's |
Awesome! Thanks for the tips, I'll give that a try and will come back here later with the results. Is there a way we can specify a different tsconfig.json when running plop? |
You can probably specify a different tsconfig if you want, but first I would ask why you feel that you need to do that. Usually you actually don't need to specify a different tsconfig because any |
This issue is really two things:
Since # 1 is the main topic of discussion in this particular issue, I will be closing it in favor of #297 for # 2 |
How to reproduce
yarn install plop
plopfile.ts
:yarn run plop
Expected behavior
plop prints a user prompt, generates files
Actual behavior
Versions
Node version: 12.3.0
Plop version: 2.5.3
The text was updated successfully, but these errors were encountered: