-
Notifications
You must be signed in to change notification settings - Fork 122
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
Re-Simplify external modules #85
Comments
Where do propose to get the imported variable name from... the file name of the TS file as in the right-most element in the require path? Can you think of a good way to have grunt-ts allow for aliasing a require? I use requirejs in my project at runtime and In this case, I would like for the relative paths to exist in my config for require, but the libraries themselves to just be aliased simply. For example, something like this would be amazing:
grunt-ts might change the TypeScript to:
And then perhaps edit the emitted JS in a post-build step from this:
to this:
To ask a silly question - I'm assuming that it's impossible for this to work in Visual Studio, right? |
You suggestion is actually quite good. But not going to be a part of this, Reason: It will only cater for requirejs whereas the plan here is to simplify for both amd/commonjs. PS: grunt-ts doesn't know about the generated js (yet).
I am trying to minimize keystrokes / config. People can rename their file to be
Possible. But no one has done tight integration yet. I suspect microsoft will add grunt support to visual studio at some point, since it has become a vital part of javascript development. Ofcourse if you have grunt-ts running in the background (and configured for watching) and modify the file in visual studio, the file should update before your eyes in visual studio.
interesting you used @nycdotnet Thank you for reviewing this! |
This is all great stuff. Thanks for considering it. The idea that it would be good to have TypeScript be able to alias modules in the emitted JS is https://typescript.codeplex.com/workitem/2317 I would love for you to vote on it/promote it if you agree with the idea. I find it fascinating that you are optimizing for inches on the keyboard. You must develop code at an extraordinary pace if your keyboard layout affects your design choices. Can't wait for your new external modules video. |
it shouldn't generate
Not at all. I was only justifying my probably bad naming decision :) Its "probably" (not final till I commit the code) going to end up as:
so that it namespaced |
@nycdotnet deployed to npm as |
for anyone interested you can see fast compile + external modules code generation working in this code sample : https://github.com/basarat/demo-fullstack/tree/master/src I will document it better once I get time |
Its out the door. And I already think it needs more configurability. e.g. When we want to "actually" load all the files in a folder it will not work since a simple So I'll bump the major version and introduce :
The export option will generate New Feature tracking : #88 |
I tried it. It makes for a cumbersome syntax (inline json in a comment) and didn't like it. So decided to make it a different codegen task (calling these transforms). Updated #88 accordingly. So this task (import transform) will remain valid (and useful) |
Thanks for your hard work on this. I'm glad that you feel comfortable iterating on this if you try and dislike the first outcome. From: Basarat Ali Syedmailto:[email protected] I tried it. It makes for a cumbersome syntax (inline json in a comment) and didn't like it. So decided to make it a different codegen task (calling these transforms). Updated #88 accordingly. So this task (import transform) will remain valid (and useful) Reply to this email directly or view it on GitHub: |
Have you put any more thought into providing a syntax to allow aliasing of the generated imports? |
Nope. You are welcome to open a new issue with this subject if you want. |
Using the
index
option does help for large projects. But for quickly getting off the ground there was too much effort required in configuration. See : Deprecation Reasons. The new plan below is simple to understand, and requires no task configuration.New Version:
Updated based on final code commited
User types in
///ts:import=filename
grunt-ts comes along, notices this and replaces it with
User types in
///ts:import=foldername
grunt-ts comes along, notices this and replaces it with
If a folder has an
index.ts
inside of it then we do not import the entire folder and only importindex.ts
. i.e :You can also use grunt-ts to create an index file for you.
To see a fullstack application that uses this : https://github.com/basarat/demo-fullstack/blob/master/src/server/routes/index.ts
The text was updated successfully, but these errors were encountered: