Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Schematics: Run local a schematic written in TypeScript directly (ts-node integration) #13858

Open
lacolaco opened this issue Mar 8, 2019 · 8 comments
Labels
area: devkit/schematics feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors feature Issue that requests a new feature
Milestone

Comments

@lacolaco
Copy link
Contributor

lacolaco commented Mar 8, 2019

馃殌 Feature request

Command (mark with an x)

- [x] schematics

Description

Schematics runner can accept a JavsScript file as a factory of a schematic.
To create boilerplates in my app, it seems a good solution to create local schematics. But it is not easy to get ready.
Writing schematics without TypeScript's help is tough and unsafe. But schematics cannot use them. We have to do manually transpiling with tsc and executing the output JS. Very primitive and boring.

Describe the solution you'd like

If schematics runner can handle TypeScript files directly, developers are free from non-essencial jobs and the repository can keep clean.

I think ts-node/register can help it.

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Mar 11, 2019

Hi, In general, I don't think shipping or transpile TypeScript at runtime is a good idea as it opens a whole new pandora box.

Compiling a .ts file to .js is dependent on a couple of factors which might vary from one project to another.

  1. tsconfig - this can be different from one project to another and hence might cause failure of a transpilation which in another project might work.
  2. tsc version, syntax that works with this current typescript version, might not be able to be compiled in the next/previous version.

Apart from that consumers of a schematic, shouldn't care if it's written in TypeScript or vanilla JavaScript and hence when compiling at runtime they might get a TypeScript error, which for them are un-actionable and irrelevant. Also, the consumers might need to install dev only dependencies which otherwise won't have too. Such as an @types/ package.

@lacolaco
Copy link
Contributor Author

@alan-agius4 Shipping TS is not good, totally I agree. I've mentioned about only project local use of schematics. It's a common demand that scaffolding some application code in project local.

@alan-agius4
Copy link
Collaborator

@lacolaco, yeah in your case, ts-node might work, however this would mean a couple of things.

  1. Schematic runner would need to be aware made aware of a tsconfig file path, as otherwise ts-node might resolve an incorrect tsconfig.
  2. API features which are specific only for local schematics.

@lacolaco
Copy link
Contributor Author

lacolaco commented Mar 11, 2019

Technically, I don't want to introduce ts-node in the CLI. I just want to run schematics with ts-node.

Currently, schematics-cli is doing many jobs. It is designed as a general reference implementation of schematics runner but technically I don't think it is easy to implement another tool equivalent to that.
I think it is needed that a JavaScript API which can be used with less configuration. It wraps @angular_devkit/schematics and contains the preset "workflow" as well as CLI.

If it can be executed in Node.js script with well-abstracted easy API, I can run just ts-node run-my-schematics.ts.

@lacolaco
Copy link
Contributor Author

something like schematics-cli-js maybe I need. 馃

@alan-agius4 alan-agius4 added the needs: discussion On the agenda for team meeting to determine next steps label Mar 14, 2019
@hansl
Copy link
Contributor

hansl commented Mar 14, 2019

Hi @lacolaco,

This is a great feature request. Unfortunately the schematics CLI is not a priority right now, but we do accept pull requests to add features like these. I'm going to remove the need further discussion, but let us know if you can implement that we can help you answer questions.

@angular-robot
Copy link
Contributor

angular-robot bot commented Feb 1, 2022

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

@ngbot ngbot bot modified the milestones: Backlog, needsTriage Feb 1, 2022
@angular-robot
Copy link
Contributor

angular-robot bot commented Feb 21, 2022

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

@angular-robot angular-robot bot added feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors and removed feature: votes required Feature request which is currently still in the voting phase labels Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: devkit/schematics feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors feature Issue that requests a new feature
Projects
None yet
Development

No branches or pull requests

3 participants