Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-cli-typescript

Package Overview
Dependencies
Maintainers
3
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-cli-typescript - npm Package Compare versions

Comparing version 0.4.0 to 1.0.0-beta.2

.idea/cli-typescript.iml

11

blueprints/ember-cli-typescript/files/tsconfig.json
{
"compilerOptions": {
"target": "ES6",
"target": "es2017",
"allowJs": true,

@@ -8,2 +8,3 @@ "moduleResolution": "node",

"noEmit": true,
"sourceMap": true,
"baseUrl": ".",

@@ -15,6 +16,8 @@ "paths": {

},
"include": [
"app/**/*",
"tests/**/*"
"exclude": [
"tmp",
"dist",
"node_modules",
"bower_components"
]
}

@@ -1,14 +0,16 @@

var path = require('path');
/* eslint-env node */
const path = require('path');
module.exports = {
description: 'Initialize files needed for typescript compilation',
files: function() {
files() {
return [
path.join(this.path, 'files', 'tsconfig.json'),
path.join(this.path, 'files', 'app', 'config', 'environment.d.ts')
path.join(this.path, 'files', 'app', 'config', 'environment.d.ts'),
];
},
mapFile: function() {
mapFile() {
const result = this._super.mapFile.apply(this, arguments);

@@ -27,12 +29,14 @@

normalizeEntityName: function() {
normalizeEntityName() {
// Entity name is optional right now, creating this hook avoids an error.
},
afterInstall: function() {
afterInstall() {
return this.addPackagesToProject([
{ name: 'typescript', target: '^2.1' },
{ name: '@types/ember', target: '^2.7.34' }
{ name: 'typescript', target: '^2.4.2' },
{ name: '@types/ember', target: '^2.7.43' },
{ name: '@types/rsvp', target: '^3.3.0' },
{ name: '@types/ember-testing-helpers' },
]);
}
}
},
};

@@ -1,2 +0,2 @@

/*jshint node:true*/
/* eslint-env node */
'use strict';

@@ -3,0 +3,0 @@

@@ -1,11 +0,7 @@

/* jshint node: true */
/* eslint-env node */
'use strict';
var path = require('path');
var process = require('process');
let TsPreprocessor;
try {
TsPreprocessor = require('./lib/typescript-preprocessor');
} catch ( ex ) {
} catch (ex) {
// Do nothing; we just won't have the plugin available. This means that if you

@@ -20,16 +16,9 @@ // somehow end up in a state where it doesn't load, the preprocessor *will*

included: function(app) {
this._super.included.apply(this, arguments);
this.app = app;
},
blueprintsPath: function() {
return path.join(__dirname, 'blueprints');
},
setupPreprocessorRegistry: function(type, registry) {
setupPreprocessorRegistry(type, registry) {
if (!TsPreprocessor) {
console.log("Note: TypeScript preprocessor not available -- some dependencies not installed. (If this is during installation of the add-on, this is as expected. If it is while building, serving, or testing the application, this is an error.)");
this.ui.write(
'Note: TypeScript preprocessor not available -- some dependencies not installed. ' +
'(If this is during installation of the add-on, this is as expected. If it is ' +
'while building, serving, or testing the application, this is an error.)'
);
return;

@@ -39,10 +28,10 @@ }

try {
var plugin = new TsPreprocessor({includeExtensions: ['.ts','.js']});
registry.add('js', plugin);
} catch ( ex ) {
console.log( "Missing or invalid tsconfig.json, please fix or run `ember generate ember-cli-typescript`." );
console.log( ' ' + ex.toString());
registry.add('js', new TsPreprocessor());
} catch (ex) {
this.ui.write(
'Missing or invalid tsconfig.json, please fix or run `ember generate ember-cli-typescript`.'
);
this.ui.write(' ' + ex.toString());
}
}
},
};

@@ -0,1 +1,2 @@

/* eslint-env node */
const fs = require('fs');

@@ -5,97 +6,53 @@ const path = require('path');

const debug = require('debug')('ember-cli-typescript');
const find = require('broccoli-stew').find;
const Funnel = require("broccoli-funnel");
const MergeTrees = require("broccoli-merge-trees");
const ts = require('typescript');
const funnel = require('broccoli-funnel');
const mergeTrees = require('broccoli-merge-trees');
const tsc = require('broccoli-typescript-compiler').typescript;
const UnwatchedDir = require('broccoli-source').UnwatchedDir;
function readConfig(configFile) {
const result = ts.readConfigFile(configFile, ts.sys.readFile);
if (result.error) {
const message = ts.flattenDiagnosticMessageText(result.error.messageText, "\n");
throw new Error(message);
}
return result.config;
}
const BroccoliDebug = require('broccoli-debug');
/**
* Return the paths which contain type information.
*/
function typePaths(config) {
const base = ["node_modules/@types"];
let tag = 0;
const cfgPaths = (config.compilerOptions && config.compilerOptions.paths) || {};
const toTypePaths = paths => (splitPaths, key) => {
// paths may end in a `/*`; keep everything before it
const upToSlashStar = path => path.split("/\*")[0];
// only store unique paths
const notAlreadyStoredIn = storedPaths => path => !storedPaths.includes(path);
const newPaths = paths[key]
.map(upToSlashStar)
.filter(notAlreadyStoredIn(splitPaths));
return splitPaths.concat(newPaths);
};
const out = Object.keys(cfgPaths).reduce(toTypePaths(cfgPaths), base);
debug("type paths", out);
return out;
}
class TypeScriptPreprocessor {
constructor(options) {
debug('creating new instance with options ', options);
this.name = 'ember-cli-typescript';
this.ext = 'ts';
this.options = JSON.parse(JSON.stringify(options));
this._tag = tag++;
// Update the config for how Broccoli handles the file system: no need for
// includes, always emit, and let Broccoli manage any outDir.
this.config = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'tsconfig.json')));
this.config.compilerOptions.noEmit = false;
delete this.config.compilerOptions.outDir;
delete this.config.include;
}
toTree(inputNode, inputPath, outputPath) {
const tsconfig = readConfig(path.join(".", "tsconfig.json"));
// The `include` setting is meant for the IDE integration; broccoli manages
// manages its own input files.
tsconfig.include = ["**/*.ts"];
// tsc needs to emit files on the broccoli pipeline, but not in the default
// config. Otherwise its compiled `.js` files may be created inadvertently.
tsconfig.compilerOptions.noEmit = false;
delete tsconfig.compilerOptions.outDir;
// Create a funnel with the type files used by the typescript compiler.
// These will change infrequently (read: usually not at all) so grab each as
// an *unwatched* directory, and return it at the proper location.
const typeTrees = typePaths(tsconfig).map((typePath) => {
const typeTree = new UnwatchedDir(typePath);
return new Funnel(typeTree, { destDir: typePath });
const js = funnel(inputNode, {
exclude: ['**/*.ts'],
annotation: 'JS files',
});
const types = new MergeTrees(typeTrees);
const debugTree = BroccoliDebug.buildDebugCallback('ember-cli-typescript');
// Passthrough all the javascript files existing in the source/test folders.
const passthrough = new Funnel(inputNode, {
exclude: ["**/*.ts"],
annotation: "TypeScript passthrough"
});
const uncompiledTs = debugTree(
funnel(inputNode, {
include: ['**/*.ts'],
annotation: 'uncompiled TS files',
}),
`${this._tag}`
);
// Files to run through the typescript compiler.
const filter = new MergeTrees([
types,
new Funnel(inputNode, {
include: ["**/*.ts"],
annotation: "TypeScript input"
})
]);
const ts = debugTree(
tsc(uncompiledTs, {
throwOnError: !this.config.compilerOptions.noEmitOnError,
annotation: 'Compiled TS files',
include: ['**/*'],
tsconfig: this.config,
}),
`${this._tag}`
);
// Put everything together.
return new MergeTrees([
passthrough,
tsc(filter, { tsconfig })
], {
return mergeTrees([js, ts], {
overwrite: true,
annotation: "TypeScript passthrough + ouput"
annotation: 'merged JS & compiled TS',
});

@@ -102,0 +59,0 @@ }

{
"name": "ember-cli-typescript",
"version": "0.4.0",
"version": "1.0.0-beta.2",
"description": "Allow ember apps to use typescript files.",

@@ -10,4 +10,5 @@ "keywords": [

"license": "MIT",
"author": "Marius Seritan",
"author": "Chris Krycho <chris@chriskrycho.com> (http://www.chriskrycho.com)",
"contributors": [
"Marius Seritan",
"David Gardiner",

@@ -31,2 +32,3 @@ "Philip Bjorge"

"dependencies": {
"broccoli-debug": "^0.6.3",
"broccoli-funnel": "^1.0.6",

@@ -37,35 +39,34 @@ "broccoli-merge-trees": "^1.1.4",

"broccoli-stew": "^1.4.0",
"broccoli-typescript-compiler": "^1.0.1",
"broccoli-typescript-compiler": "^2.0.0",
"debug": "^2.2.0",
"ember-cli-babel": "^5.1.7"
"ember-cli-babel": "^6.3.0"
},
"devDependencies": {
"@types/ember": "^2.7.34",
"@types/ember": "^2.7.43",
"broccoli-asset-rev": "^2.4.5",
"ember-ajax": "^2.4.1",
"ember-cli": "2.10.0",
"ember-cli": "^2.13.3",
"ember-cli-app-version": "^2.0.0",
"ember-cli-dependency-checker": "^1.3.0",
"ember-cli-htmlbars": "^1.0.10",
"ember-cli-htmlbars-inline-precompile": "^0.3.3",
"ember-cli-eslint": "^3.0.0",
"ember-cli-htmlbars": "^1.1.1",
"ember-cli-htmlbars-inline-precompile": "^0.4.0",
"ember-cli-inject-live-reload": "^1.4.1",
"ember-cli-jshint": "^2.0.1",
"ember-cli-qunit": "^3.0.1",
"ember-cli-qunit": "^4.0.0",
"ember-cli-release": "^0.2.9",
"ember-cli-shims": "^1.1.0",
"ember-cli-sri": "^2.1.0",
"ember-cli-test-loader": "^1.1.0",
"ember-cli-uglify": "^1.2.0",
"ember-disable-prototype-extensions": "^1.1.0",
"ember-export-application-global": "^1.0.5",
"ember-load-initializers": "^0.5.1",
"ember-resolver": "^2.0.3",
"loader.js": "^4.0.10",
"typescript": "^2.1.0"
"ember-disable-prototype-extensions": "^1.1.2",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.0.0",
"ember-resolver": "^4.0.0",
"ember-source": "~2.13.3",
"loader.js": "^4.2.3",
"typescript": "^2.4.2"
},
"peerDependencies": {
"@types/ember": "^2.7.34",
"typescript": "^2.1.0"
"typescript": "^2.4.2"
},
"engines": {
"node": ">= 0.12.0"
"node": "^4.5 || 6.* || >= 7.*"
},

@@ -72,0 +73,0 @@ "ember-addon": {

@@ -34,3 +34,13 @@ # ember-cli-typescript

### :warning: Warning: install size
This is a WIP :construction: part of the add-on, and it *will* make a dramatic
difference in the size of your add-on in terms of installation. (It won't affect
the size of the add-on after build, of course!)
We're working on making a solution that lets us ship generated typings and
compiled JavaScript instead of shipping the entire TypeScript compiler toolchain
for add-ons. If you're using ember-cli-typescript in an add-on, you might add a
note to your users about the install size until we get that sorted out!
## Configuration file notes

@@ -77,3 +87,3 @@

Please see [the wiki] for additional how to tips from other users or to add
Please see [the wiki] for additional how to tips from other users or to add
your own tips. If an use case is frequent enough we can codify in the plugin.

@@ -120,3 +130,3 @@

}
```
```

@@ -131,3 +141,3 @@ ### Type safety when invoking actions

}
```
```

@@ -160,3 +170,22 @@ ```hbs

});
```
```
### The TypeDefs I need to reference are not in node_modules/@types
By default `ember-cli-typescript` loads up any type defs found in node_modules/@types. If the type defs you need are not found here you can register a custom `path` in the tsconfig.json file
```json
// tsconfig.json
{
"compilerOptions": {
"paths": {
"welp/*": ["app/*"],
"redux": ["node_modules/redux/index.d.ts"]
}
},
"include": [
"**/*.ts"
]
}
```

@@ -11,4 +11,4 @@ {

"include": [
"app/**/*"
"**/*"
]
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc