Giter Club home page Giter Club logo

Comments (19)

gilamran avatar gilamran commented on June 24, 2024 1

Looks very good!
lets do it in a new major version.

from tsc-watch.

gilamran avatar gilamran commented on June 24, 2024 1

@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.

gilamran avatar gilamran commented on June 24, 2024 1

@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?

image

from tsc-watch.

gilamran avatar gilamran commented on June 24, 2024 1

@pp0rtal Lets move the discussion to #145

from tsc-watch.

pp0rtal avatar pp0rtal commented on June 24, 2024

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.

gilamran avatar gilamran commented on June 24, 2024

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.

pp0rtal avatar pp0rtal commented on June 24, 2024

@gilamran Sure!
PR about this issue is coming soon. In any case take your time for the ESM switch

from tsc-watch.

pp0rtal avatar pp0rtal commented on June 24, 2024

@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
image

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.

gilamran avatar gilamran commented on June 24, 2024

Thanks, I'll check it out.

from tsc-watch.

gilamran avatar gilamran commented on June 24, 2024

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.

pp0rtal avatar pp0rtal commented on June 24, 2024

@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.

pp0rtal avatar pp0rtal commented on June 24, 2024

@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:

"include": ["src/client/index.ts"]

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

const tscWatch = require.resolve(join(process.cwd(), 'dist', 'lib', 'tsc-watch'));

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.

gilamran avatar gilamran commented on June 24, 2024

@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.

pp0rtal avatar pp0rtal commented on June 24, 2024

@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
image

By emitting all files type and client source are emitted
image

from tsc-watch.

pp0rtal avatar pp0rtal commented on June 24, 2024

@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.

pp0rtal avatar pp0rtal commented on June 24, 2024

@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.

gilamran avatar gilamran commented on June 24, 2024

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.

gilamran avatar gilamran commented on June 24, 2024

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.

pp0rtal avatar pp0rtal commented on June 24, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.