Code Monkey home page Code Monkey logo

broccoli-typescript-compiler's People

Contributors

arthurvr avatar asakusuma avatar bekzod avatar chadhietala avatar chancancode avatar davewasmer avatar dependabot[bot] avatar ef4 avatar givanse avatar hhff avatar jayphelps avatar joliss avatar jschiq2 avatar krisselden avatar locks avatar lynchbomb avatar markuskobler avatar nightire avatar peterood avatar philipbjorge avatar rwjblue avatar sebmck avatar smfoote avatar stefanpenner avatar theseyi avatar thoov avatar tomdale avatar twokul avatar wagenet avatar wycats avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

broccoli-typescript-compiler's Issues

Uses cached version on first rebuild

I am experiencing the following:

When running broccoli in watch mode, the first time I edit a file, the change is not reflected in the output of the build. I can trace in the /tmp/broccoli-/out- dirs that the broccoli pipeline has the updated file in all node output dirs until broccoli-typescript-compiler. Subsequent edits work fine.

Example: Suppose BTC compiles file x.ts containg foo: number = 1 to foo = 1. Then when first starting broccoli in watch mode, it will correctly output foo = 1. We make an edit:

foo: number = 2

but BTC still outputs foo = 1. Now we make a second edit:

foo: number = 3

and BTC now correctly outupts foo = .

Any ideas what can be wrong, and if there is a fix or a workaround?

Support for TypeScript 2.6.x

Currently b-t-c supports TypeScript ~2.5.2. The latest version of TS is 2.6.1.
Upgrading to this version is a breaking change but one that would need to be supported soon to take advantage of new features like strict parameter contravariance with strictFunctionTypes, // @ts-ignore pragma, etc

Support incremental compilation via TS API

As of TypeScript 2.7, the incremental compilation is exported as public API โ€“ see PR here. This should enable broccoli-typescript-compiler to work directly with it, enabling much faster (and cleaner) incremental rebuilds.

Thanks and Future Plans?

I appreciate you writing this package -- It looks to be the best option to use typescript with broccoli available, even if it is a WIP.

I've used it to put together the following repo which I hope to test and improve on in the coming weeks to see what Ember TS integration could look like.

https://github.com/philipbjorge/ember-cli-typescript
(Any tips would be greatly appreciated on this as I'm new to the ember ecosystem)

Is there anything on the roadmap for this package?
Also, is this being used internally at tilde?

process.cwd in constructor is not correct

this.options = parseOptions((options && options.tsconfig) || path.join(process.cwd(), "tsconfig.json"));

the tsconfig is not guarenteed to be at the cwd when:

  1. broccoli-typescript-compiler is used by a dependencies to build itself
  2. the CLI invocation happens elsewhere in the tree.

It should be resolve relative to the __dirname of the invocation of the typescript plugin. ember-cli uses: https://github.com/ember-cli/ember-cli/blob/master/lib/utilities/get-caller-file.js to find the file of the caller. Something similar could be used. But then it will still need to findup to handle the variable cwd cases

cc @chancancode .

Use Typescript Language Services

Currently this plugin does not exam the entire TypeScript program and I believe this is the cause of the pain in Glimmer where it appears the program has no type errors, but when you go to CI the build fails. The angular team has their own TS plugin that does incremental rebuilds of the program. I think we need to either a) ask them to extract this or b) incorporate their learnings.

`throwOnError` doesn't work in dev mode

If there's a TypeScript error, and throwOnError is set to true, and you run a dev build, you'll see the errors in the console, but the build will succeed. If you run the prod build, it throws as expected.

Seen on version 2.1.0

cc @krisselden

should `typescript` be a devDependency?

atm, adding broccoli-typescript-compiler to broccoli project fail with such errors:

module.js:472                                                                                                                                                       
    throw err;                                                                                                                                            
    ^                                                                                                                                                                        
                                                                                                                                      
Error: Cannot find module 'typescript'                                                                                                                                 
    at Function.Module._resolveFilename (module.js:470:15)                                                                                                                   
    at Function.Module._load (module.js:418:25)                                                                                                                              
    at Module.require (module.js:498:17)                                                                                                                           
    at require (internal/module.js:20:19)                                                                                                                                 
    at Object.<anonymous> (/home/chrmod/Projects/chrmod/raureif-typescript/node_modules/broccoli-typescript-compiler/dist/plugin.js:5:10)      
    at Module._compile (module.js:571:32)                                                                                                
    at Object.Module._extensions..js (module.js:580:10)                                                                        
    at Module.load (module.js:488:32)                                                                                                                                            at tryModuleLoad (module.js:447:12)                                                                                                                        
    at Function.Module._load (module.js:439:3)                                                                                         
    at Module.require (module.js:498:17)                                                                                             
    at require (internal/module.js:20:19)                                                                                                                                    
    at Object.<anonymous> (/home/chrmod/Projects/chrmod/raureif-typescript/node_modules/broccoli-typescript-compiler/index.js:1:76)
    at Module._compile (module.js:571:32)                                                                             
    at Object.Module._extensions..js (module.js:580:10)                                                    
    at Module.load (module.js:488:32)    

adding typescript as dependency or devDependecy, solves the issue.

This approach allows project to control the typescript version, but also is inconvenient for newcomers. If it is intentional behavior, maybe it should be documented in README?

Semver dependency on typescript in minor range is a breaking change: TypeError: getFileSystemEntries is not a function

broccoli-typescript-compiler has a permissive package.json that depends on TypeScript version ^2.3.3. This minor range dependency currently allows Yarn to install TS 2.5.0 which is at release candidate rc stage.

https://registry.yarnpkg.com/typescript revision: 1052-fb9eebd5b091190020c3c186ce299827

{
latest: "2.4.2",
next: "2.6.0-dev.20170817",
beta: "2.0.0",
rc: "2.5.0",
insiders: "2.4.2-insiders.20170719"
},

Unfortunately, this actually breaks the broccoli build step because there is an incompatible api change:
in typescript.js, the function signature matchFiles in @2.5.0 rc, accepts an additional argument depth:

function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries) {
...
}

https://github.com/Microsoft/TypeScript/blob/v2.5-rc/src/compiler/core.ts#L2073
versus the current/latest @2.4.2 signature

function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, getFileSystemEntries) {
...
}

https://github.com/Microsoft/TypeScript/blob/v2.4.2/src/compiler/core.ts#L2023
You'll notice that the depth parameter was not previuosly present

This cause the broccoli build to throw:

TypeError: getFileSystemEntries is not a function

EDIT: updated with TS repo source links

Move typescript to peerDependencies?

broccoli-typescript-compiler currently have a version range as a dependency, making it hard to make it run with a certain version. This has been a source of confused for us on multiple occasions when trying to upgrade typescript. Also, tools like tslint requires typescript as a peerDependency.

Is there a reason typescript is a dependency and not a peerDependency?

Generating SourceMaps

Not sure if this is truly an issue or just a user error. I've been unable to generate SourceMaps. Below are the Brocfile.js, package.json, and tsconfig.json files that I'm using.

Brocfile.js

var Funnel = require('broccoli-funnel');
var BroccoliMergeTrees = require('broccoli-merge-trees');
var tsTranspiler = require('broccoli-typescript-compiler');

var indexFile = new Funnel('src', {
  files: ['index.html']
});

var appTS = tsTranspiler('src/app/');
var appJS = new Funnel(appTS, {
  destDir: 'app'
});

var vendorJS = new Funnel('node_modules', {
  files: [
    'angular2/bundles/angular2-polyfills.js',
    'systemjs/dist/system.src.js',
    'rxjs/bundles/Rx.js',
    'angular2/bundles/angular2.dev.js'
  ],
  destDir: 'vendor'
});

module.exports = new BroccoliMergeTrees(
  [indexFile, appJS, vendorJS]);

package.json

{
  "name": "my-app",
  "version": "0.1.0",
  "scripts": {
    "start": "broccoli serve",
    "build": "rm -rf dist/ && broccoli build dist"
  },
  "license": "MIT",
  "dependencies": {
    "angular2": "2.0.0-beta.1",
    "systemjs": "0.19.6",
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.33.3",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.0",
    "zone.js": "0.5.10"
  },
  "devDependencies": {
    "broccoli": "^0.16.9",
    "broccoli-funnel": "^1.0.1",
    "broccoli-merge-trees": "^1.1.1",
    "broccoli-typescript-compiler": "^0.4.1",
    "typescript": "^1.7.3"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "target": "ES5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules"
  ]
}

Release 2.1.1 with TS 2.6 support?

Since @theseyi kindly did the work to get TS 2.6 integration working, can we get a 2.1.1 with that support rolled in? I need it for things like // @ts-ignore in my app using ember-cli-typescript, and would prefer not to point that addon at master. ๐Ÿ˜ฌ

Thanks!

Presence Of TSConfig Causes Multiple Rebuilds In VSCode

Repro: https://github.com/chadhietala/typescript-compiler-repro

I'm seeing multiple rebuilds in VSCode when the tsconfig.json is present. I confirmed that when I removed the tsconfig.json that I no longer saw the rebuilds. touching or editing the file in VIM does not cause the issue. I did notice that the access time increases on the tsconfig.json every time I save a file. I'm wondering if this busting some cache every time.

โ†’ stat -x tsconfig.json                           [master]
  File: "tsconfig.json"
  Size: 3            FileType: Regular File
  Mode: (0644/-rw-r--r--)         Uid: ( 8583/chietala)  Gid: (  101/   (101))
Device: 1,4   Inode: 19864562    Links: 1
Access: Fri Aug 11 17:42:02 2017
Modify: Fri Aug 11 17:35:54 2017
Change: Fri Aug 11 17:35:54 2017

Rebuild:

โ†’ stat -x tsconfig.json                                                      [master]
  File: "tsconfig.json"
  Size: 3            FileType: Regular File
  Mode: (0644/-rw-r--r--)         Uid: ( 8583/chietala)  Gid: (  101/   (101))
Device: 1,4   Inode: 19864562    Links: 1
Access: Fri Aug 11 17:49:58 2017
Modify: Fri Aug 11 17:35:54 2017
Change: Fri Aug 11 17:35:54 2017

Create abstraction around node_modules resolution.

Currently, for type resolution to work properly between app code and npm packages you must pass in a source tree that includes a root node_modules/ directory.

I briefly spoke to @krisselden about this, and I believe we are on the same page. I'm happy to help tackle this, but need some guidance on the desired path forward...

No output on compile errors

Hi there,

I just started using broccoli-typescript-compiler (0.3.0) and noticed it doesn't detect compilation errors.

Relevant part of my Brocfile.js:

var compileTypeScript = require('broccoli-typescript-compiler');
var scripts = compileTypeScript(tsDir);

If I run tsc directly:

app/boot.ts(2,22): error TS1005: ',' expected.

Running broccoli build or serve works like everything is fine.

Is that expected or a known issue?

Thanks!

Support other lib files

It seems like the way the default lib file is handled that targets newer than ES2015/ES6 are not supported. This also seems to be a problem for any manually specified lib files in the tsconfig. For example, if I set my project target to ES2016, then Typescript will attempt to include additional lib files beyond the single defaultLibFileName. Since these additional lib files don't match the name of the default lib, the SourceCache will attempt to load the from the input broccoli tree rather than the Typescript module's lib folder.

I'm not sure the best way to tackle this. I have a working patch that just scans path.dirname(defaultLibFileName), and if any requested files match a lib file, it uses that lib file. Of course, this doesn't handle filename collisions between the Typescript lib files and the Broccoli input files. One option would be to check both and give precedence to the Broccoli input files.

Figured I'd file this first to see if I was missing something. Happy to PR my suggested patch, or something else.

Support passthrough without filtering...

Given the following input files:

DEBUG-handlebars-output
โ””โ”€โ”€ src
    โ”œโ”€โ”€ index.ts
    โ””โ”€โ”€ ui
        โ”œโ”€โ”€ components
        โ”‚ย ย  โ””โ”€โ”€ foo-bar.js
        โ””โ”€โ”€ index.html

Using require('broccoli-typescript-compiler').typescript, the following is the output:

DEBUG-rollup-input-tree
โ””โ”€โ”€ index.js

If we use the default export (e.g. require('broccoli-typescript-compiler')) directly, we end up running two pretty costly Funnel's to include: ['**.ts'] (in typescript tree) and exclude: ['**.ts'] (from passthrough tree) then merge the two back together.

Doing include / exclude operations like this forces us to stat all of the input tree (which is often very large, and includes node_modules).

Opening this issue to start the dialogue on the best path forward...

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.