Comments (19)
Looks very good!
lets do it in a new major version.
from tsc-watch.
@pp0rtal I've converted the project to Typescript, you can see it here: https://github.com/gilamran/tsc-watch/tree/v5
Please review if you can.
Thanks
from tsc-watch.
@pp0rtal That's very strange. when telling typescript to emit a file that import
another file it will also emit the imported file. what are we missing here?
from tsc-watch.
@pp0rtal Lets move the discussion to #145
from tsc-watch.
Hi @gilamran
I've already fixes ready to go PR, but I created an issue for the record
If you like it, let's go ahead.
ps: thanks for your lib :)
from tsc-watch.
BTW, I want to upgrade to node 12.12.x and use ESM modules (which is actually required already) in this major upgrade
from tsc-watch.
@gilamran Sure!
PR about this issue is coming soon. In any case take your time for the ESM switch
from tsc-watch.
@gilamran Cool you initiated the project π
(minor note) You can put tsconfig.json
at project root (alongside package.json) that usually what I see in projects and what tsc
will search for by default.
More importantly, I didn't succeed to make type works :/
I'm using the following import on /client
which is documented but there is an error now with types
Probably this file https://github.com/gilamran/tsc-watch/blob/v5/index.js should expose the client directly and not anything else, to match your statement in package.json "types": "types/client.d.ts",
// index.js
module.exports.TscWatchClient = require('./dist/client').TscWatchClient;
// -- other file
// Example of working usage
import { TscWatchClient } from "tsc-watch";
But I'm afraid this won't fit a direct tsc-watch
usage, I'm not sure to understand how you designed it.
What about emitting the types alongside the JS files?
You may drop the legacy index.js
, and just create a lib/index.ts
, and make package.json point on it.
You will be less bothered in the future
// package.json
"exports": "./dist/tsc-watch.js",
"main": "dist/index.js",
"types": "dist/index.d.ts",
You lib/index.ts
#!/usr/bin/env node
export {TscWatchClient} from "./client";
// not sure tsc-watch can be imported? It's just an exposed .bin?
// import * as tscAlias from "./tsc-watch";
// export default tscAlias;
from tsc-watch.
Thanks, I'll check it out.
from tsc-watch.
I did some big changed to the structure. please review. I want to publish an alpha version so we can test it properly
from tsc-watch.
@gilamran Great! I'll do a full try by next week! π
I'll suggest also my changes (not a long PR) after yours relatively to this topic, I was waiting for your update.
Have a good WE
from tsc-watch.
@gilamran I gave a try to the latest v5
, good job!
2 important remarks:
Client is not compiled
(dist/client/client.js
is not emitted!) because:
tsc-watch/tsconfig-client.json
Line 16 in 41f58c6
should match all Ts files in the folder
src/client/**/*.ts
will fix
The client can't require tsc-watch lib
Concretely it is searching inside my project, and not ths tsc-client package, see:
Error: Cannot find module '/MY_PJ_ROOT/dist/lib/tsc-watch'
Require stack:
- /MY_PJ_ROOT/node_modules/tsc-watch/dist/client/client.js
- /MY_PJ_ROOT/node_modules/tsc-watch/dist/client/index.js
- /MY_PJ_ROOT/gulpfile.ts
That's because the client can be launched with a different process folder
tsc-watch/src/client/client.ts
Line 9 in 41f58c6
I advise to search tsc-watch relatively to the client:
const tscWatch = require.resolve(join(__dirname, '..', 'lib', 'tsc-watch'));
Except this, types for the client works perfectly well π―
from tsc-watch.
@pp0rtal regarding 1 I don't understand why you think that client.js is not emitted... as long as the index.ts
is requiring (import) client.ts
typescript will emit it. please double check it.
regarding 2, right! fixed and pushed. retry please
from tsc-watch.
@gilamran
As you are specifying to only generate the client index (src/client/index.ts
) I do have only an index.d.ts
,
Did you filter index.ts on purpose?
The problem is that client/index.ts
requires client/client.ts
file
By emitting all files type and client source are emitted
from tsc-watch.
@gilamran Hello, I don't know if my last message made sense,
but it works great if you include all client files for the tsconfig-client
As soon you merge the Ts refactor, I can open a PR about this issue.
from tsc-watch.
@gilamran Ok I found why (I don't know the real explaination to this)
I was tryign your project inside my project/nod_modules/
, when I run in it I don't have emitted files.
(Ideally I know I should have symlinked the project to link out of my node_modules)
See:
mkdir node_modules ; cd node_modules # same bug when in any sub dir of node_modules
git clone [email protected]:gilamran/tsc-watch.git ; cd tsc-watch ; git checkout v5 ; npm install
npm run build ; ls dist/client/
index.d.ts index.js
Why Typescript doesn't work correctly when inside a directly node_modules
,
some internal security of Typescript to prevent building files not belonging to a project?
In any case you can let your config, as long you build the client.d.ts
:)
from tsc-watch.
Yea, probably a typescript thing. treating node_modules
as a special case.
Anyways, I've started converting the tests to typescript as well, so we wont have to require from ../../dist
etc.
I hope that I'll have an alpha version to install via npm soon.
from tsc-watch.
ok, did another big change:
- Converted to jest (instead of mocha)
- Converted tests to Typescript!
@pp0rtal Please review, I want to release an alpha
from tsc-watch.
@gilamran Just had a look to 2dac2ee and tried locally.
Test passes on my machine, and stack looks more sustainable, good job π
As soon you mere on master I will also open a PR to not make tsc crash silently. In any case you can release.
Thanks for all those upgrades π
from tsc-watch.
Related Issues (20)
- Be able to tweak `node` memory HOT 2
- Support Β for `--listEmittedFiles` + new message `file_emitted` HOT 3
- `--onSuccess exit` causing a crash HOT 2
- black on black text HOT 6
- Please tag published versions HOT 2
- index.js contains DOS line endings since version 5.0.1 HOT 2
- Support for TypeScript Project References / --build mode HOT 6
- tsc-watch fails to restart node server on source file changes within a docker bind mount HOT 12
- Please add a --no-watch option HOT 7
- Document how to use --incremental? HOT 4
- Wrong export of TscWatchClient in version 6.0.0 HOT 8
- How to make tsc-watch exit if COMMAND exits unexpectedly HOT 1
- On windows compiler path issue. HOT 6
- How to pass the node environment? HOT 2
- tsc-watch re-compiling even when no file was modified HOT 4
- Best tool for the job HOT 5
- "TypeError: es.split is not a function" Error when change a file and compile HOT 2
- Add `--onEachCompilationStarted` option HOT 1
- Add some options HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tsc-watch.