tildeio / broccoli-typescript-compiler Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
It appears this may be intentional based on the last paragraph in the readme and this comment, but it seems like this is undesirable behavior.
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"
]
}
Apparently [email protected] was published to npm, but neither the code nor the tag are included in this repo.
I'll try to come up with something reproducible in the next few days.
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. touch
ing 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
Since #64 has been merged, can the updated npm version with TS 2.8.x support be released shortly?
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?
Basically I think the last processed file is the only one available in the sourcemaps.
Used here: https://github.com/tildeio/libkit/blob/master/lib/ember-cli-build/typescript.js
Related issue: tildeio/libkit#5
Code you can run: https://github.com/knownasilya/google-maps-drawing-tools (running npm run tdd
will let you open the browser with the tests.)
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
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.
cc @krisselden
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!
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.
We're using matchFiles()
, which is still private from what I can tell. Related ticket: microsoft/TypeScript#13793
Looks like matchFiles
requires a new parameter in [email protected]. @krisselden can you take a look at trying to fix this and upgrade to 3.4.1?
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?
Looks like quite a bit has changed since last October, including a change which I believe fixes the root cause of an issue I'm having on ember-cli-typescript. Can we please get a fresh version pushed to npm? Thanks!
Neither of these functions appear to exist in 1.7.3: ts.parseConfigFile()
ts.convertCompilerOptionsFromJson
https://github.com/tildeio/broccoli-typescript-compiler/blob/master/index.js#L46-L49
"Cannot load tsconfig.json from ..." gets thrown
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...
After upgrading from 4.1.0
to 4.2.0
, my addon build time increased by more than 4x.
I suspect this has something to do with the TypeScript upgrade.
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.
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
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!
broccoli-typescript-compiler/index.js
Line 78 in 973a8cf
the tsconfig is not guarenteed to be at the cwd when:
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 .
we should be sure to correctly handle deletes.
This should allow us to do more performant incremental builds
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
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?
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?
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...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.