Code Monkey home page Code Monkey logo

ts-loader's People

Contributors

andrewbranch avatar appzuka avatar arcanis avatar berickson1 avatar brooooooklyn avatar christiantinauer avatar dependabot[bot] avatar freeman avatar g-plane avatar greenkeeper[bot] avatar greenkeeperio-bot avatar herringtondarkholme avatar jbrantly avatar johnnyreilly avatar jonwallsten avatar jsjoeio avatar loilo avatar maier49 avatar manuth avatar mblandfo avatar opichals avatar piotr-oles avatar renovate[bot] avatar sheetalkamat avatar smphhh avatar timocov avatar trodrigues avatar use-strict avatar wearymonkey avatar zn4rk 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ts-loader's Issues

Support multiple entry points

Webpack allows defining multiple entry points, eg:

    entry: {
        page1: "./page1",
        page2: "./page2"
    }

I'm not entirely sure what the desired behavior should be here but some possible topics of discussion.

  1. Does each entry point get its own instance of the TS language service? I think the answer is yes.
  2. Can each entry point specify it's own tsconfig, and if so how?
  3. Can each entry point specify its own loader options, and if so how?

Double check watch mode support

Reported by @s-panferov.

We should double check that watch mode works as expected. In theory files that are actually passed through webpack are watched and reloaded just fine, including incremental compilation. However, it's likely that dependent files which are not passed through webpack (such as declaration files) are not watched.

failed when upgrade to typescript 1.6.2

Hi @jbrantly

I just upgraded Typescript to 1.6.2 and it gives me the following error

ts-loader: Using typescript@1.6.2 and C:\Projects\Midwinter.ReasonableBasis\Midwinter.AdviceOS.Web\tsconfig.json
C:\Projects\Midwinter.ReasonableBasis\Midwinter.AdviceOS.Web\node_modules\typescript\lib\typescript.js:1573
                throw new Error("Debug Failure. False expression: " + (message
                ^
Error: Debug Failure. False expression: How could we be trying to update a document that the registry doesn't have?
    at Object.assert (C:\Projects\Midwinter.ReasonableBasis\Midwinter.AdviceOS.Web\node_modules\typescript\lib\typescript.js:1573:23)
    at acquireOrUpdateDocument (C:\Projects\Midwinter.ReasonableBasis\Midwinter.AdviceOS.Web\node_modules\typescript\lib\typescript.js:43097:26)
    at Object.updateDocument (C:\Projects\Midwinter.ReasonableBasis\Midwinter.AdviceOS.Web\node_modules\typescript\lib\typescript.js:43091:20)
    at Object.getOrCreateSourceFile [as getSourceFile] (C:\Projects\Midwinter.ReasonableBasis\Midwinter.AdviceOS.Web\node_modules\typescript\lib\typescript.js:43709:49)
    at tryReuseStructureFromOldProgram (C:\Projects\Midwinter.ReasonableBasis\Midwinter.AdviceOS.Web\node_modules\typescript\lib\typescript.js:35508:42)
    at Object.createProgram (C:\Projects\Midwinter.ReasonableBasis\Midwinter.AdviceOS.Web\node_modules\typescript\lib\typescript.js:35444:14)
    at synchronizeHostData (C:\Projects\Midwinter.ReasonableBasis\Midwinter.AdviceOS.Web\node_modules\typescript\lib\typescript.js:43651:33)
    at Object.getSyntacticDiagnostics (C:\Projects\Midwinter.ReasonableBasis\Midwinter.AdviceOS.Web\node_modules\typescript\lib\typescript.js:43755:13)
    at C:\Projects\Midwinter.ReasonableBasis\Midwinter.AdviceOS.Web\node_modules\ts-loader\index.js:304:42
    at Array.forEach (native)
Process terminated with code 1.

Do you have any idea on how to fix this error?

cheers,
Khoa

Watch tsconfig.json

It would be ideal if tsconfig.json could be watched for changes. I think this would have to result in the creation of a whole new language service instance.

Path is missing from source maps

I tried your loader in a test project and found out that the path is missing from the source maps.

For example:

  • App
    • Component
      • Page.jsx
      • Helper.ts

end up in Chrome as:

  • App
    • Component
      • Page.jsx
  • Helper.ts

I compared your loader with the jsx-loader and saw that the jsx-loader sets two additional properties on the sourcemap. (sources and files)

I changed your code and it works now: (basically a copy from jsx-loader)

...

    if (options.sourceMap) {
        var sourceFilename = loaderUtils.getRemainingRequest(this);
        var current = loaderUtils.getCurrentRequest(this);
        sourceMap = JSON.parse(output.outputFiles[0].text);
        sourceMap.sources = [sourceFilename];
        sourceMap.file = current;
        sourceMap.sourcesContent = [contents];
        contents = output.outputFiles[1].text;
    }

...

Does this look ok to you?

Could you incorporate this change in your code and npm module?

Thanks!

Errors in d.ts files not reported

There are "d.ts" files in my project which have some errors. These kind of errors are not accessible from the webpack API callback and are only written to the console. The code responsible for this seems to be at line 177 in index.js. The errors are logged after the compilation is done, so the callback doesn't see them. Not sure if intended or not, but there is no way for me to retrieve them, other that hackish regex matching on stdout.

I'm currently working on a watcher to integrate the webpack build with PhpStorm and I need to output errors in a strict format ($file$ ($line$, $col$): $message$) without other redundant output.

Remove sourceMappingURL from output

Reported by @schlaup in #8. Opening as a new issue here.

From @schlaup:

Ok, thanks, I just discovered an additional problem:

Typescript places its own "//# sourceMappingURL=SomeFile.ts" in the JavaScript output.

So the bundle.js files ends up with multiple "# sourceMappingURL" declarations. (Of course, only the last "# sourceMappingURL=bundle.js.map" is valid)

It seems that Chrome does not care, but other tools do. (For example "NPM source-map-support")

The solution is to remove the redundant and incorrect "sourceMappingURL" declaration.

I added another line:

if (options.sourceMap) {
    var sourceFilename = loaderUtils.getRemainingRequest(this);
    var current = loaderUtils.getCurrentRequest(this);
    sourceMap = JSON.parse(output.outputFiles[0].text);
    sourceMap.sources = [sourceFilename];
    sourceMap.file = current;
    sourceMap.sourcesContent = [contents];
    contents = output.outputFiles[1].text;

This line here:

    contents = contents.replace("# sourceMappingURL=", " ");
}

This solves the problem.

noImplicitAny

I would like to use --no-implicit-any, can you expose this as an option?

Ideally, you would allow passing through options the loader doesn't know about to Typescript, so one wouldn't need to make such requests in the future, if possible?

Export = { } throws an error

name.ts

export = {
"firstname" : "abc" ,
"lastname" : "def"
}

main.ts

import * as details from './name';

I am encountering the following error when webpack bundles the files

Module '"name"' resolves to a non-module entity and cannot be imported using this construct.

Doesn't work with nightly builds of typescript (1.6)

Need to try out jsx react support so when I use the nightly builds of typescript npm install ntypescript I get error.

D:\temp\reactjs-typescript-boilerplate>npm run build

> [email protected] build D:\temp\reactjs-typescript-boilerpl
ate
> webpack --config=webpack.config.js --progress --colors --devtool source-map

 50% 2/3 build modulesUsing config file at D:\temp\reactjs-typescript-boilerplat
e\src\tsconfig.json
Hash: 4752b7dc0a2e5b3df26e
Version: webpack 1.10.1
Time: 328ms
   [0] multi app 28 bytes {0} [built] [1 error]
   [0] multi app.specs 16 bytes {1} [built]
    + 1 hidden modules

ERROR in ./src/App.tsx
Module build failed: TypeError: host.readDirectory is not a function
    at getFileNames (D:\temp\reactjs-typescript-boilerplate\node_modules\ntypesc
ript\bin\typescript.js:34793:37)
    at Object.parseConfigFile (D:\temp\reactjs-typescript-boilerplate\node_modul
es\ntypescript\bin\typescript.js:34740:24)
    at ensureTypeScriptInstance (D:\temp\reactjs-typescript-boilerplate\node_mod
ules\ts-loader\index.js:83:42)
    at Object.loader (D:\temp\reactjs-typescript-boilerplate\node_modules\ts-loa
der\index.js:191:20)
 @ multi app

You can repo the issue from https://github.com/prabirshrestha/reactjs-typescript-boilerplate/tree/webpack (webpack) branch

npm install
npm run build

given that TS 1.6 is not officially out might be better to have an alpha version of ts-loader.

Could not find file /react/package.json

Hi James, love your work on this loader and your blog posts on jsx with typescript, it's helped a ton!

Just being thorough in posting this here, I originally reported this as an issue to TypeScript (microsoft/TypeScript#4445) but was advised that it might not be their bug. As advised I have thrown it up on StackOverflow (http://stackoverflow.com/questions/32211875/webpack-typescript-cannot-find-file-node-modules-react-package-json) and cross posted the issue here and to WebPack's issue tracker (webpack/webpack#1393)

I had this working yesterday on a fresh npm install, but this morning after a fresh install I was out of luck. So I'm at a bit of a loss for what happened.

I am using typescript@next with webpack and ts-loader.

When running Webpack I am receiving the following error from typescript.js:43445

C:\Users\Michael\Development\Replicate>webpack
Using config file at C:\Users\Michael\Development\Replicate\tsconfig.json
C:\Users\Michael\Development\Replicate\node_modules\typescript\lib\typescript.js:43445
                throw new Error("Could not find file: '" + fileName + "'.");
                      ^
Error: Could not find file: 'C:/Users/Michael/Development/Replicate/node_modules/react/package.json'.
    at getValidSourceFile (C:\Users\Michael\Development\Replicate\node_modules\typescript\lib\typescript.js:43445:23)
    at Object.getSyntacticDiagnostics (C:\Users\Michael\Development\Replicate\node_modules\typescript\lib\typescript.js:43615:52)
    at C:\Users\Michael\Development\Replicate\node_modules\ts-loader\index.js:186:42
    at Array.forEach (native)
    at Compiler.<anonymous> (C:\Users\Michael\Development\Replicate\node_modules\ts-loader\index.js:185:14)
    at Compiler.applyPlugins (C:\Users\Michael\AppData\Roaming\npm\node_modules\webpack\node_modules\tapable\lib\Tapable.js:26:37)
    at Compiler.<anonymous> (C:\Users\Michael\AppData\Roaming\npm\node_modules\webpack\lib\Compiler.js:193:12)
    at Compiler.emitRecords (C:\Users\Michael\AppData\Roaming\npm\node_modules\webpack\lib\Compiler.js:282:37)
    at Compiler.<anonymous> (C:\Users\Michael\AppData\Roaming\npm\node_modules\webpack\lib\Compiler.js:187:11)
    at C:\Users\Michael\AppData\Roaming\npm\node_modules\webpack\lib\Compiler.js:275:11
    at Compiler.applyPluginsAsync (C:\Users\Michael\AppData\Roaming\npm\node_modules\webpack\node_modules\tapable\lib\Tapable.js:60:69)
    at Compiler.afterEmit (C:\Users\Michael\AppData\Roaming\npm\node_modules\webpack\lib\Compiler.js:272:8)
    at Compiler.<anonymous> (C:\Users\Michael\AppData\Roaming\npm\node_modules\webpack\lib\Compiler.js:267:14)
    at C:\Users\Michael\AppData\Roaming\npm\node_modules\webpack\node_modules\async\lib\async.js:52:16
    at done (C:\Users\Michael\AppData\Roaming\npm\node_modules\webpack\node_modules\async\lib\async.js:248:21)
    at C:\Users\Michael\AppData\Roaming\npm\node_modules\webpack\node_modules\async\lib\async.js:44:16
    at FSReqWrap.oncomplete (fs.js:95:15)

my package.json

{
  "name": "Replicate",
  "version": "1.0.0",
  "description": "Reproducing typescript file not found bug",
  "main": "webpack.config.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Michael Ross",
  "license": "MIT",
  "dependencies": {
    "react": "^0.13.3",
    "ts-loader": "^0.5.0",
    "typescript": "^1.6.0-dev.20150825"
  }
}

my webpack.config.js

module.exports = {
    entry: "./app.tsx",
    output: {
        filename: "bundle.js"
    },
    resolve: {
        extensions: ["", ".tsx", ".ts", ".js"]
    },
    module: {
        loaders: [
            { test: /\.ts(x?)$/, loader: "ts-loader" }
        ]
    }
}

my app.tsx

import React = require('react');

class Demo extends React.Component<any, any> {
    render() {
        return <div>Trying to replicate</div>
    }
}

React.render(<Demo />, document.getElementById("demo"));

and just in case, my tsconfig.json

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "jsx": "react",
        "sourceMap": true
    },
    "files": [
        "./typings/tsd.d.ts",
        "./app.tsx"
    ]
}

and tsd.json

{
  "version": "v4",
  "repo": "borisyankov/DefinitelyTyped",
  "ref": "master",
  "path": "typings",
  "bundle": "typings/tsd.d.ts",
  "installed": {
    "react/react.d.ts": {
      "commit": "71a7d5306ae4f9893aafd2d85d38aac8789ebf33"
    }
  }
}

If I have a configuration error, help and guidance is much appreciated. Thanks!

Typescript package dependency

Hello, can you please consider removing typescript from package "dependencies" and adding it to peerDependencies and devDependencies?
The "compiler" option allows to switch to ntypescript but not typescript@next, ts-loader@^0.4 works fine after I manually moved the dependency.

  "peerDependencies": {
    "typescript": ">=1.5.3"
  },
  "devDependencies": {
    "typescript": ">=1.5.3"
  }

The only drawback is that with npm@3 (npm/npm#6565) the peerDependencies will not be installed automatically but IMHO returning to the host project control over the typescript version is more important.

Thanks for the loader!

Does not work with typescript 1.5-beta

I tried to upgrade the package.json and installing a new typescript in the ts-loader, but it didn't work just by doing that. For instance I get this:

C:\Projects\HTML5\model-validation-ghpages\src\node_modules\ts-loader\index.js:76
                getLength: function () { return file.text.length; },
                                                    ^
TypeError: Cannot read property 'text' of undefined
    at Object.getLength (C:\Projects\HTML5\model-validation-ghpages\src\node_modules\tsloader\index.js:76:53)

I also tried this: https://github.com/s-panferov/awesome-typescript-loader but apparently it doesn't work with your ts-jsx-loader.

Fun times with TS and JS, lots of breaking stuff at the moment.

whitespaces eating in markup

@jbrantly Hello!
in rendered markup i haven't whitespaces which was in source code.
its reason why my styles crashed. is this propblem of loader or maybe with react?
Thank you!

Support for 1.6

Is there anything that needs updating to support 1.6?

Thanks!

"Could not load TypeScript. Try installing with `npm install -g typescript`"

I updated to 0.5.2 from 0.5.0 this morning but still seem to be having the same issue although the new error message is less useful for problem identification. After receiving the error message, I updated typescript to the latest nightly build using 'npm install -g typescript@next'.

Any insights would be appreciated.

Here's my webpack.config.js:

'use strict';

var webpack = require('webpack');
var WebpackNotifierPlugin = require('webpack-notifier');

module.exports = {
  entry: './server/server.ts',
  output: {
    path: './build/',
    filename: 'server.js'
  },
  plugins: [
    new webpack.optimize.OccurenceOrderPlugin(),
    new WebpackNotifierPlugin()
  ],
  resolve: {
    extensions: ['', '.webpack.js', '.web.js', '.js', '.jsx', '.ts', '.tsx']
  },
  module: {
    loaders: [
      {
        test: /\.jsx$/,
        exclude: ['./node_modules/'],
        loader: 'babel-loader'
      },
      {
        test: /\.ts(x?)$/,
        exclude: ['./node_modules/'],
        loader: 'ts-loader'
      }
    ]
  }
};

And here is the tsconfig.js:

{
    "compilerOptions": {
        "module": "commonjs",
        "noImplicitAny": true,
        "removeComments": true,
        "preserveConstEnums": true,
        "target": "ES5",
        "sourceMap": true
    }
}

With 0.5.0, the error message was:
ERROR in ./server/server.ts

Module build failed: Error: Cannot find module 'typescript'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at ensureTypeScriptInstance (partial path elided .../node_modules/ts-loader/index.js:69:20)
at Object.loader (partial path elided .../node_modules/ts-loader/index.js:228:14)

ts loader should resolve relative path's which not starts with './'

Hello @jbrantly !
Thank you for this loader!
I have question
for example we uses import * as mm from '../../MyFolder/myModule';
not will be resolved when call ts-loader, but if we use
'./../../MyFolder/myModule' - all cool.
ts compiler allow use relative paths, which can starts with './' and without it.
What do you think about it?

Support tsconfig.json files

We should try to add support for tsconfig.json files prior to the release of TS 1.5. See microsoft/TypeScript#1692

Part of this change should also include updating the additionalFiles configuration to just be files which matches what is in the configuration file.

ts-loader with typescript 1.6 and tsx

I've been trying to use ts-loader with tsx files that have jsx in them. Unfortunately, webpack always throws this error:

ERROR in ./app/index.tsx
Module build failed: error TS5012: Cannot read file '/Users/me/Documents/engineering/project/tsconfig.json': undefined is not a function

I don't think this is a problem with my tsconfig.json because it works fine with tsc from the command line and the gulp-typescript module. Any help here would be much appreciated as this is the only thing keeping me from using this loader!

Support for TypeScript JSX files (.tsx)

TypeScript 1.6 has a new feature: support for JSX syntax.

This is especially useful for those who want to use the ReactJS framework.

This ts-loader gives the following error when I attempt to get it to compile .tsx files:

TS17004: Cannot use JSX unless the '--jsx' flag is provided.

Do you think we could get the loader to add the --jsx flag if the file ends with .tsx?

If you want to test for yourself, just change version of TypeScript in the dependency list in package.json to 1.6.0-beta and have a basic .tsx file:

export class Hello {
  function greet(s:string):void {
    // do nothing
  }
}

Changes not being detected by devServer / hot replacement

When I change a file in watch mode, webpack seems to build but browser says no changes detected. There is only one typescript file in the project other than the type files. Building in non-watch mode works fine.

version: 0.3.3

ES6 export default doesn't work with require.ensure

Howdy,

It looks like require.ensure doesn't work with export default. If you were to take the example and change c.ts and/or d.ts to use export default you should be able to repro the issue. Example:

a.ts:
export default 'a';

c.ts:
export default 'c';

app.ts:
import a from './a';
import b = require('./b');
// modules c and d won't actually be emitted as "require" calls here
// since they are not used directly. Instead, they are only referenced
// with "typeof". At this point, these statements are only for the
// benefit of the TypeScript type system.
import c from './c';
import d = require('./d');

console.log(a);
console.log(b);
require.ensure(['./c', './d'], function(require) {
    // These require calls are emitted (note these are NOT TypeScript
    // `import ... require` statements). `require.ensure` is defined in
    // require.d.ts. Webpack sees this and automatically puts c and d
    // into a separate chunk. 
    var c:string = <typeof c>require('./c');
    var d:string = <typeof d>require('./d');
    console.log(c);
    console.log(d);
});

Output:

bundle1.js:
    var a_1 = __webpack_require__(1);
    var b = __webpack_require__(2);
    console.log(a_1["default"]);
    console.log(b);
    __webpack_require__.e/* nsure */(1, function (require) {
        // These require calls are emitted (note these are NOT TypeScript
        // `import ... require` statements). `require.ensure` is defined in
        // require.d.ts. Webpack sees this and automatically puts c and d
        // into a separate chunk. 
        var c = __webpack_require__(3);
        var d = __webpack_require__(4);
        console.log(c);
        console.log(d);
    });

/***/ },
/* 1 */
/***/ function(module, exports) {

    exports["default"] = 'a';


/***/ },
/* 2 */
/***/ function(module, exports) {

    module.exports = 'b';


/***/ }

1.bundle.js:
webpackJsonp([1],[
/* 0 */,
/* 1 */,
/* 2 */,
/* 3 */
/***/ function(module, exports) {

    exports["default"] = 'c';


/***/ },
/* 4 */
/***/ function(module, exports) {

    module.exports = 'd';


/***/ }
]);

output:
a
b
Object {default: "c"}
d

The normal import works fine. I've been unable to get anything working inside require.ensure. Is this not yet supported?

Can't npm install

I can't seem to install the latest version (0.3.4 works fine though). I've tried this on both a windows and a mac machine with the same result complaining about the Typescript dependency. Here is the npm-debug.log:

0 info it worked if it ends with ok
1 verbose cli [ 'node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'install',
1 verbose cli '--save-dev',
1 verbose cli 'ts-loader' ]
2 info using [email protected]
3 info using [email protected]
4 verbose install initial load of /Users/rich/repos/react-experiment/package.json
5 verbose installManyTop reading scoped package data from /Users/rich/repos/react-experiment/node_modules/babel-core/package.json
6 verbose installManyTop reading scoped package data from /Users/rich/repos/react-experiment/node_modules/babel-loader/package.json
7 verbose installManyTop reading scoped package data from /Users/rich/repos/react-experiment/node_modules/browserify/package.json
8 verbose installManyTop reading scoped package data from /Users/rich/repos/react-experiment/node_modules/gulp/package.json
9 verbose installManyTop reading scoped package data from /Users/rich/repos/react-experiment/node_modules/gulp-concat/package.json
10 verbose installManyTop reading scoped package data from /Users/rich/repos/react-experiment/node_modules/jsx-typescript/package.json
11 verbose installManyTop reading scoped package data from /Users/rich/repos/react-experiment/node_modules/react/package.json
12 verbose installManyTop reading scoped package data from /Users/rich/repos/react-experiment/node_modules/reactify/package.json
13 verbose installManyTop reading scoped package data from /Users/rich/repos/react-experiment/node_modules/vinyl-source-stream/package.json
14 verbose installManyTop reading scoped package data from /Users/rich/repos/react-experiment/node_modules/watchify/package.json
15 verbose installManyTop reading scoped package data from /Users/rich/repos/react-experiment/node_modules/webpack/package.json
16 verbose readDependencies loading dependencies from /Users/rich/repos/react-experiment/package.json
17 silly cache add args [ 'ts-loader', null ]
18 verbose cache add spec ts-loader
19 silly cache add parsed spec { raw: 'ts-loader',
19 silly cache add scope: null,
19 silly cache add name: 'ts-loader',
19 silly cache add rawSpec: '',
19 silly cache add spec: '',
19 silly cache add type: 'range' }
20 silly addNamed ts-loader@

21 verbose addNamed "" is a valid semver range for ts-loader
22 silly addNameRange { name: 'ts-loader', range: '
', hasData: false }
23 silly mapToRegistry name ts-loader
24 silly mapToRegistry using default registry
25 silly mapToRegistry registry https://registry.npmjs.org/
26 silly mapToRegistry uri https://registry.npmjs.org/ts-loader
27 verbose addNameRange registry:https://registry.npmjs.org/ts-loader not in flight; fetching
28 verbose request uri https://registry.npmjs.org/ts-loader
29 verbose request no auth needed
30 info attempt registry request try #1 at 2:46:45 PM
31 verbose request id 01ae7f3b603eef89
32 verbose etag "66CFYLWB7QSOXNDOLP2OJ0LZ8"
33 http request GET https://registry.npmjs.org/ts-loader
34 http 304 https://registry.npmjs.org/ts-loader
35 silly get cb [ 304,
35 silly get { date: 'Fri, 08 May 2015 21:46:45 GMT',
35 silly get via: '1.1 varnish',
35 silly get 'last-modified': 'Fri, 08 May 2015 21:46:45 GMT',
35 silly get 'cache-control': 'max-age=60',
35 silly get etag: '"66CFYLWB7QSOXNDOLP2OJ0LZ8"',
35 silly get age: '0',
35 silly get connection: 'keep-alive',
35 silly get 'x-served-by': 'cache-lax1434-LAX',
35 silly get 'x-cache': 'MISS',
35 silly get 'x-cache-hits': '0',
35 silly get 'x-timer': 'S1431121605.570647,VS0,VE146',
35 silly get vary: 'Accept' } ]
36 verbose etag https://registry.npmjs.org/ts-loader from cache
37 verbose get saving ts-loader to /Users/rich/.npm/registry.npmjs.org/ts-loader/.cache.json
38 silly addNameRange number 2 { name: 'ts-loader', range: '_', hasData: true }
39 silly addNameRange versions [ 'ts-loader',
39 silly addNameRange [ '0.1.0',
39 silly addNameRange '0.2.0',
39 silly addNameRange '0.2.1',
39 silly addNameRange '0.2.2',
39 silly addNameRange '0.2.3',
39 silly addNameRange '0.3.0',
39 silly addNameRange '0.3.1',
39 silly addNameRange '0.3.2',
39 silly addNameRange '0.3.3',
39 silly addNameRange '0.3.4',
39 silly addNameRange '0.4.0',
39 silly addNameRange '0.4.1' ] ]
40 silly addNamed [email protected]
41 verbose addNamed "0.4.1" is a plain semver version for ts-loader
42 silly cache afterAdd [email protected]
43 verbose afterAdd /Users/rich/.npm/ts-loader/0.4.1/package/package.json not in flight; writing
44 verbose afterAdd /Users/rich/.npm/ts-loader/0.4.1/package/package.json written
45 silly install resolved [ { name: 'ts-loader',
45 silly install resolved version: '0.4.1',
45 silly install resolved description: 'TypeScript loader for webpack',
45 silly install resolved main: 'index.js',
45 silly install resolved scripts:
45 silly install resolved { pretest: 'tsc index.ts --module commonjs',
45 silly install resolved test: 'node ./node_modules/mocha/bin/mocha --reporter spec test/run.js',
45 silly install resolved prepublish: 'tsc index.ts --module commonjs' },
45 silly install resolved repository:
45 silly install resolved { type: 'git',
45 silly install resolved url: 'git+https://github.com/jbrantly/ts-loader.git' },
45 silly install resolved keywords:
45 silly install resolved [ 'ts-loader',
45 silly install resolved 'typescript-loader',
45 silly install resolved 'webpack',
45 silly install resolved 'loader',
45 silly install resolved 'typescript',
45 silly install resolved 'ts' ],
45 silly install resolved author:
45 silly install resolved { name: 'James Brantly',
45 silly install resolved email: '[email protected]',
45 silly install resolved url: 'http://www.jbrantly.com/' },
45 silly install resolved license: 'MIT',
45 silly install resolved bugs: { url: 'https://github.com/jbrantly/ts-loader/issues' },
45 silly install resolved homepage: 'https://github.com/jbrantly/ts-loader',
45 silly install resolved dependencies:
45 silly install resolved { colors: '^1.0.3',
45 silly install resolved 'loader-utils': '^0.2.6',
45 silly install resolved 'object-assign': '^2.0.0',
45 silly install resolved typescript: '~1.5.0' },
45 silly install resolved devDependencies:
45 silly install resolved { 'jsx-typescript': '^1.5.0-alpha.4',
45 silly install resolved mocha: '^2.1.0',
45 silly install resolved webpack: '^1.5.3' },
45 silly install resolved gitHead: 'c4394142f71e1565f10b0fd24225f2ce615ee3b8',
45 silly install resolved _id: '[email protected]',
45 silly install resolved _shasum: '786772f4eec0a9e2891ca18cbcc188518a2c701b',
45 silly install resolved from: 'ts-loader@',
45 silly install resolved _npmVersion: '1.4.28',
45 silly install resolved _npmUser: { name: 'jbrantly', email: '[email protected]' },
45 silly install resolved maintainers: [ [Object] ],
45 silly install resolved dist:
45 silly install resolved { shasum: '786772f4eec0a9e2891ca18cbcc188518a2c701b',
45 silly install resolved tarball: 'http://registry.npmjs.org/ts-loader/-/ts-loader-0.4.1.tgz' },
45 silly install resolved directories: {},
45 silly install resolved _resolved: 'https://registry.npmjs.org/ts-loader/-/ts-loader-0.4.1.tgz',
45 silly install resolved readme: 'ERROR: No README data found!' } ]
46 info install [email protected] into /Users/rich/repos/react-experiment
47 info installOne [email protected]
48 verbose installOne of ts-loader to /Users/rich/repos/react-experiment not in flight; installing
49 verbose lock using /Users/rich/.npm/_locks/ts-loader-3e1df6fff3206756.lock for /Users/rich/repos/react-experiment/node_modules/ts-loader
50 silly install write writing ts-loader 0.4.1 to /Users/rich/repos/react-experiment/node_modules/ts-loader
51 verbose unbuild node_modules/ts-loader
52 silly gentlyRm /Users/rich/repos/react-experiment/node_modules/ts-loader is being purged from base /Users/rich/repos/react-experiment
53 verbose gentlyRm don't care about contents; nuking /Users/rich/repos/react-experiment/node_modules/ts-loader
54 verbose tar unpack /Users/rich/.npm/ts-loader/0.4.1/package.tgz
55 verbose tar unpacking to /Users/rich/repos/react-experiment/node_modules/ts-loader
56 silly gentlyRm /Users/rich/repos/react-experiment/node_modules/ts-loader is being purged
57 verbose gentlyRm don't care about contents; nuking /Users/rich/repos/react-experiment/node_modules/ts-loader
58 silly gunzTarPerm modes [ '755', '644' ]
59 silly gunzTarPerm extractEntry package.json
60 silly gunzTarPerm modified mode [ 'package.json', 436, 420 ]
61 silly gunzTarPerm extractEntry .npmignore
62 silly gunzTarPerm modified mode [ '.npmignore', 436, 420 ]
63 silly gunzTarPerm extractEntry README.md
64 silly gunzTarPerm modified mode [ 'README.md', 436, 420 ]
65 silly gunzTarPerm extractEntry LICENSE
66 silly gunzTarPerm modified mode [ 'LICENSE', 436, 420 ]
67 silly gunzTarPerm extractEntry index.js
68 silly gunzTarPerm modified mode [ 'index.js', 436, 420 ]
69 silly gunzTarPerm extractEntry CHANGELOG.md
70 silly gunzTarPerm modified mode [ 'CHANGELOG.md', 436, 420 ]
71 silly gunzTarPerm extractEntry UPGRADE.md
72 silly gunzTarPerm modified mode [ 'UPGRADE.md', 436, 420 ]
73 verbose write writing to /Users/rich/repos/react-experiment/node_modules/ts-loader/package.json
74 info preinstall [email protected]
75 verbose readDependencies loading dependencies from /Users/rich/repos/react-experiment/node_modules/ts-loader/package.json
76 silly prepareForInstallMany adding colors@^1.0.3 from ts-loader dependencies
77 silly prepareForInstallMany adding loader-utils@^0.2.6 from ts-loader dependencies
78 silly prepareForInstallMany adding object-assign@^2.0.0 from ts-loader dependencies
79 silly prepareForInstallMany adding typescript@~1.5.0 from ts-loader dependencies
80 verbose readDependencies loading dependencies from /Users/rich/repos/react-experiment/node_modules/ts-loader/package.json
81 silly cache add args [ 'colors@^1.0.3', null ]
82 verbose cache add spec colors@^1.0.3
83 silly cache add args [ 'loader-utils@^0.2.6', null ]
84 verbose cache add spec loader-utils@^0.2.6
85 silly cache add parsed spec { raw: 'colors@^1.0.3',
85 silly cache add scope: null,
85 silly cache add name: 'colors',
85 silly cache add rawSpec: '^1.0.3',
85 silly cache add spec: '>=1.0.3 <2.0.0',
85 silly cache add type: 'range' }
86 silly addNamed colors@>=1.0.3 <2.0.0
87 verbose addNamed ">=1.0.3 <2.0.0" is a valid semver range for colors
88 silly addNameRange { name: 'colors', range: '>=1.0.3 <2.0.0', hasData: false }
89 silly mapToRegistry name colors
90 silly mapToRegistry using default registry
91 silly mapToRegistry registry https://registry.npmjs.org/
92 silly mapToRegistry uri https://registry.npmjs.org/colors
93 verbose addNameRange registry:https://registry.npmjs.org/colors not in flight; fetching
94 silly cache add parsed spec { raw: 'loader-utils@^0.2.6',
94 silly cache add scope: null,
94 silly cache add name: 'loader-utils',
94 silly cache add rawSpec: '^0.2.6',
94 silly cache add spec: '>=0.2.6 <0.3.0',
94 silly cache add type: 'range' }
95 silly addNamed loader-utils@>=0.2.6 <0.3.0
96 verbose addNamed ">=0.2.6 <0.3.0" is a valid semver range for loader-utils
97 silly addNameRange { name: 'loader-utils', range: '>=0.2.6 <0.3.0', hasData: false }
98 silly mapToRegistry name loader-utils
99 silly mapToRegistry using default registry
100 silly mapToRegistry registry https://registry.npmjs.org/
101 silly mapToRegistry uri https://registry.npmjs.org/loader-utils
102 verbose addNameRange registry:https://registry.npmjs.org/loader-utils not in flight; fetching
103 silly cache add args [ 'object-assign@^2.0.0', null ]
104 verbose cache add spec object-assign@^2.0.0
105 silly cache add parsed spec { raw: 'object-assign@^2.0.0',
105 silly cache add scope: null,
105 silly cache add name: 'object-assign',
105 silly cache add rawSpec: '^2.0.0',
105 silly cache add spec: '>=2.0.0 <3.0.0',
105 silly cache add type: 'range' }
106 silly addNamed object-assign@>=2.0.0 <3.0.0
107 verbose addNamed ">=2.0.0 <3.0.0" is a valid semver range for object-assign
108 silly addNameRange { name: 'object-assign',
108 silly addNameRange range: '>=2.0.0 <3.0.0',
108 silly addNameRange hasData: false }
109 silly mapToRegistry name object-assign
110 silly mapToRegistry using default registry
111 silly mapToRegistry registry https://registry.npmjs.org/
112 silly mapToRegistry uri https://registry.npmjs.org/object-assign
113 verbose addNameRange registry:https://registry.npmjs.org/object-assign not in flight; fetching
114 silly cache add args [ 'typescript@~1.5.0', null ]
115 verbose cache add spec typescript@~1.5.0
116 silly cache add parsed spec { raw: 'typescript@~1.5.0',
116 silly cache add scope: null,
116 silly cache add name: 'typescript',
116 silly cache add rawSpec: '~1.5.0',
116 silly cache add spec: '>=1.5.0 <1.6.0',
116 silly cache add type: 'range' }
117 silly addNamed typescript@>=1.5.0 <1.6.0
118 verbose addNamed ">=1.5.0 <1.6.0" is a valid semver range for typescript
119 silly addNameRange { name: 'typescript', range: '>=1.5.0 <1.6.0', hasData: false }
120 silly mapToRegistry name typescript
121 silly mapToRegistry using default registry
122 silly mapToRegistry registry https://registry.npmjs.org/
123 silly mapToRegistry uri https://registry.npmjs.org/typescript
124 verbose addNameRange registry:https://registry.npmjs.org/typescript not in flight; fetching
125 verbose request uri https://registry.npmjs.org/colors
126 verbose request no auth needed
127 info attempt registry request try #1 at 2:46:45 PM
128 verbose etag "4T0EZRMD070K0EW827B38XR8G"
129 http request GET https://registry.npmjs.org/colors
130 verbose request uri https://registry.npmjs.org/typescript
131 verbose request no auth needed
132 info attempt registry request try #1 at 2:46:45 PM
133 verbose etag "5HTGGVSQOAABIHTKL08UVTAD9"
134 http request GET https://registry.npmjs.org/typescript
135 verbose request uri https://registry.npmjs.org/loader-utils
136 verbose request no auth needed
137 info attempt registry request try #1 at 2:46:45 PM
138 verbose etag "BKY6H9I5OCVZVB1G07Q6PP85Y"
139 http request GET https://registry.npmjs.org/loader-utils
140 verbose request uri https://registry.npmjs.org/object-assign
141 verbose request no auth needed
142 info attempt registry request try #1 at 2:46:45 PM
143 verbose etag "1WKYIZVJKREFK4HYXVMP3C9MW"
144 http request GET https://registry.npmjs.org/object-assign
145 http 304 https://registry.npmjs.org/colors
146 silly get cb [ 304,
146 silly get { date: 'Fri, 08 May 2015 21:46:45 GMT',
146 silly get via: '1.1 varnish',
146 silly get 'last-modified': 'Fri, 08 May 2015 21:21:34 GMT',
146 silly get 'cache-control': 'max-age=60',
146 silly get etag: '"4T0EZRMD070K0EW827B38XR8G"',
146 silly get age: '39',
146 silly get connection: 'keep-alive',
146 silly get 'x-served-by': 'cache-lax1428-LAX',
146 silly get 'x-cache': 'HIT',
146 silly get 'x-cache-hits': '344',
146 silly get 'x-timer': 'S1431121605.997762,VS0,VE0',
146 silly get vary: 'Accept' } ]
147 verbose etag https://registry.npmjs.org/colors from cache
148 verbose get saving colors to /Users/rich/.npm/registry.npmjs.org/colors/.cache.json
149 http 304 https://registry.npmjs.org/object-assign
150 silly get cb [ 304,
150 silly get { date: 'Fri, 08 May 2015 21:46:46 GMT',
150 silly get via: '1.1 varnish',
150 silly get 'cache-control': 'max-age=60',
150 silly get etag: '"1WKYIZVJKREFK4HYXVMP3C9MW"',
150 silly get age: '55',
150 silly get connection: 'keep-alive',
150 silly get 'x-served-by': 'cache-lax1423-LAX',
150 silly get 'x-cache': 'HIT',
150 silly get 'x-cache-hits': '3',
150 silly get 'x-timer': 'S1431121606.003761,VS0,VE0',
150 silly get vary: 'Accept' } ]
151 verbose etag https://registry.npmjs.org/object-assign from cache
152 verbose get saving object-assign to /Users/rich/.npm/registry.npmjs.org/object-assign/.cache.json
153 http 304 https://registry.npmjs.org/loader-utils
154 silly get cb [ 304,
154 silly get { date: 'Fri, 08 May 2015 21:46:46 GMT',
154 silly get via: '1.1 varnish',
154 silly get 'cache-control': 'max-age=60',
154 silly get etag: '"BKY6H9I5OCVZVB1G07Q6PP85Y"',
154 silly get age: '49',
154 silly get connection: 'keep-alive',
154 silly get 'x-served-by': 'cache-lax1421-LAX',
154 silly get 'x-cache': 'HIT',
154 silly get 'x-cache-hits': '51',
154 silly get 'x-timer': 'S1431121606.006522,VS0,VE0',
154 silly get vary: 'Accept' } ]
155 verbose etag https://registry.npmjs.org/loader-utils from cache
156 verbose get saving loader-utils to /Users/rich/.npm/registry.npmjs.org/loader-utils/.cache.json
157 silly addNameRange number 2 { name: 'colors', range: '>=1.0.3 <2.0.0', hasData: true }
158 silly addNameRange versions [ 'colors',
158 silly addNameRange [ '0.3.0',
158 silly addNameRange '0.5.0',
158 silly addNameRange '0.5.1',
158 silly addNameRange '0.6.0',
158 silly addNameRange '0.6.0-1',
158 silly addNameRange '0.6.1',
158 silly addNameRange '0.6.2',
158 silly addNameRange '1.0.0',
158 silly addNameRange '1.0.1',
158 silly addNameRange '1.0.2',
158 silly addNameRange '1.0.3',
158 silly addNameRange '1.1.0' ] ]
159 silly addNamed [email protected]
160 verbose addNamed "1.1.0" is a plain semver version for colors
161 silly addNameRange number 2 { name: 'object-assign', range: '>=2.0.0 <3.0.0', hasData: true }
162 silly addNameRange versions [ 'object-assign',
162 silly addNameRange [ '0.1.0',
162 silly addNameRange '0.1.1',
162 silly addNameRange '0.1.2',
162 silly addNameRange '0.2.0',
162 silly addNameRange '0.2.1',
162 silly addNameRange '0.2.2',
162 silly addNameRange '0.3.0',
162 silly addNameRange '0.3.1',
162 silly addNameRange '0.4.0',
162 silly addNameRange '1.0.0',
162 silly addNameRange '2.0.0' ] ]
163 silly addNamed [email protected]
164 verbose addNamed "2.0.0" is a plain semver version for object-assign
165 silly addNameRange number 2 { name: 'loader-utils', range: '>=0.2.6 <0.3.0', hasData: true }
166 silly addNameRange versions [ 'loader-utils',
166 silly addNameRange [ '0.1.0',
166 silly addNameRange '0.1.1',
166 silly addNameRange '0.1.2',
166 silly addNameRange '0.2.0',
166 silly addNameRange '0.2.1',
166 silly addNameRange '0.2.2',
166 silly addNameRange '0.2.3',
166 silly addNameRange '0.2.4',
166 silly addNameRange '0.2.5',
166 silly addNameRange '0.2.6',
166 silly addNameRange '0.2.7' ] ]
167 silly addNamed [email protected]
168 verbose addNamed "0.2.7" is a plain semver version for loader-utils
169 silly cache afterAdd [email protected]
170 verbose afterAdd /Users/rich/.npm/colors/1.1.0/package/package.json not in flight; writing
171 silly cache afterAdd [email protected]
172 verbose afterAdd /Users/rich/.npm/object-assign/2.0.0/package/package.json not in flight; writing
173 silly cache afterAdd [email protected]
174 verbose afterAdd /Users/rich/.npm/loader-utils/0.2.7/package/package.json not in flight; writing
175 verbose afterAdd /Users/rich/.npm/colors/1.1.0/package/package.json written
176 verbose afterAdd /Users/rich/.npm/loader-utils/0.2.7/package/package.json written
177 verbose afterAdd /Users/rich/.npm/object-assign/2.0.0/package/package.json written
178 http 304 https://registry.npmjs.org/typescript
179 silly get cb [ 304,
179 silly get { date: 'Fri, 08 May 2015 21:46:46 GMT',
179 silly get via: '1.1 varnish',
179 silly get 'last-modified': 'Fri, 08 May 2015 21:46:46 GMT',
179 silly get 'cache-control': 'max-age=60',
179 silly get etag: '"5HTGGVSQOAABIHTKL08UVTAD9"',
179 silly get age: '0',
179 silly get connection: 'keep-alive',
179 silly get 'x-served-by': 'cache-lax1432-LAX',
179 silly get 'x-cache': 'HIT',
179 silly get 'x-cache-hits': '1',
179 silly get 'x-timer': 'S1431121606.000459,VS0,VE44',
179 silly get vary: 'Accept' } ]
180 verbose etag https://registry.npmjs.org/typescript from cache
181 verbose get saving typescript to /Users/rich/.npm/registry.npmjs.org/typescript/.cache.json
182 silly addNameRange number 2 { name: 'typescript', range: '>=1.5.0 <1.6.0', hasData: true }
183 silly addNameRange versions [ 'typescript',
183 silly addNameRange [ '0.8.0',
183 silly addNameRange '0.8.1',
183 silly addNameRange '0.8.1-1',
183 silly addNameRange '0.8.2',
183 silly addNameRange '0.8.3',
183 silly addNameRange '0.9.0',
183 silly addNameRange '0.9.0-1',
183 silly addNameRange '0.9.1',
183 silly addNameRange '0.9.1-1',
183 silly addNameRange '0.9.5',
183 silly addNameRange '0.9.7',
183 silly addNameRange '1.0.0',
183 silly addNameRange '1.0.1',
183 silly addNameRange '1.1.0-1',
183 silly addNameRange '1.3.0',
183 silly addNameRange '1.4.1',
183 silly addNameRange '1.5.0-alpha',
183 silly addNameRange '1.5.0-beta' ] ]
184 verbose about to build /Users/rich/repos/react-experiment/node_modules/ts-loader
185 verbose unlock done using /Users/rich/.npm/_locks/ts-loader-3e1df6fff3206756.lock for /Users/rich/repos/react-experiment/node_modules/ts-loader
186 verbose stack Error: No compatible version found: typescript@'>=1.5.0 <1.6.0'
186 verbose stack Valid install targets:
186 verbose stack ["0.8.0","0.8.1","0.8.1-1","0.8.2","0.8.3","0.9.0","0.9.0-1","0.9.1","0.9.1-1","0.9.5","0.9.7","1.0.0","1.0.1","1.1.0-1","1.3.0","1.4.1","1.5.0-alpha","1.5.0-beta"]
186 verbose stack
186 verbose stack at installTargetsError (/usr/local/lib/node_modules/npm/lib/cache/add-named.js:262:12)
186 verbose stack at next (/usr/local/lib/node_modules/npm/lib/cache/add-named.js:241:17)
186 verbose stack at setData (/usr/local/lib/node_modules/npm/lib/cache/add-named.js:218:5)
186 verbose stack at RES (/usr/local/lib/node_modules/npm/node_modules/inflight/inflight.js:23:14)
186 verbose stack at f (/usr/local/lib/node_modules/npm/node_modules/once/once.js:17:25)
186 verbose stack at saved (/usr/local/lib/node_modules/npm/lib/cache/caching-client.js:173:7)
186 verbose stack at FSReqWrap.oncomplete (fs.js:95:15)
187 verbose cwd /Users/rich/repos/react-experiment
188 error Darwin 14.3.0
189 error argv "node" "/usr/local/bin/npm" "install" "--save-dev" "ts-loader"
190 error node v0.12.2
191 error npm v2.9.1
192 error code ETARGET
193 error notarget No compatible version found: typescript@'>=1.5.0 <1.6.0'
193 error notarget Valid install targets:
193 error notarget ["0.8.0","0.8.1","0.8.1-1","0.8.2","0.8.3","0.9.0","0.9.0-1","0.9.1","0.9.1-1","0.9.5","0.9.7","1.0.0","1.0.1","1.1.0-1","1.3.0","1.4.1","1.5.0-alpha","1.5.0-beta"]
193 error notarget
193 error notarget This is most likely not a problem with npm itself.
193 error notarget In most cases you or one of your dependencies are requesting
193 error notarget a package version that doesn't exist.
193 error notarget
193 error notarget It was specified as a dependency of 'ts-loader'
194 verbose exit [ 1, true ]
195 verbose unbuild node_modules/ts-loader
196 info preuninstall [email protected]
197 info uninstall [email protected]
198 verbose unbuild rmStuff [email protected] from /Users/rich/repos/react-experiment/node_modules
199 info postuninstall [email protected]
200 silly gentlyRm /Users/rich/repos/react-experiment/node_modules/ts-loader is being purged from base /Users/rich/repos/react-experiment
201 verbose gentlyRm don't care about contents; nuking /Users/rich/repos/react-experiment/node_modules/ts-loader
202 silly vacuum-fs purging /Users/rich/repos/react-experiment/node_modules/ts-loader
203 silly vacuum-fs quitting because other entries in /Users/rich/repos/react-experiment/node_modules

noLib option in tsconfig.json

The "noLib" compiler option doesn't work. It looks like the lib.*.d.ts file is manually added from index.js:71-75.

I don't fully understand the intent here, but from what I read on the TypeScript docs, if the files option is not specified, then the whole directory is recursively included. I assume you are including the lib manually because there is no "exclude" option and you don't want to recursively include everything.

Ideally, there should be no preprocessing of the "tsconfig.json" file. At the very least, manually check for "noLib" and add an empty dummy file instead, to override the default behavior.

Support for tsconfig.json exclude

The tsconfig.json supports an exclude option, that should be supported by this.

If I get this right, this plugin just goes for the "files" option in the tsconfig, else loads all files (regardless of webpack configuration).

Then the tsconfig.json exclude option should get supported as well. Is that possible?

declaration:true in tsconfig causes error

Hey, I would like to get a .d.ts output besides the usual bundle, So I'm trying to add this line to tsconfig.json:

declaration: true

But when I do that I get this error:

ERROR in ./init.ts Module parse failed: F:\wamp\www\davine\sites\terramaya.org\ts\trm\node_modules\ts-loader\index.j s!F:\wamp\www\davine\sites\terramaya.org\ts\trm\node_modules\ts-jsx-loader\index.js!F:\wamp\www\d avine\sites\terramaya.org\ts\trm\init.ts Line 1: Unexpected token : You may need an appropriate loader to handle this file type. | {"version":3,"file":"init.js","sourceRoot":"","sources":["init.ts"],"names":[],"mappings":"AAAA ;;GAEG;AACH,sCAAsC;.....

If I remove the declaration line from tsconfig.json it works fine.
Full tsconfig:

{
  "compilerOptions": {
    "module": "commonjs",
    "noImplicitAny": false,
    "removeComments": true,
    "preserveConstEnums": true,
    "out": "../../public_html/js/builds/trm.main.js",
    "sourceMap": true,
    "declaration":true
  },
  "files": [
    "init.ts"
  ]
}

Full webpack.config.js:

// webpack.config.js
var webpack = require('webpack');

module.exports = {
    entry: './init.ts',
    output: {
        filename: '../../public_html/js/builds/trm.main.js'
    },
    resolve: {
        extensions: ['', '.ts', '.webpack.js', '.web.js', '.js']
    },
    module: {
        loaders: [
            { test: /\.ts$/, loader: 'ts-loader!ts-jsx-loader' }
        ]
    },
    cache:false,
    watch:true,
    plugins: [
        new webpack.SourceMapDevToolPlugin(
            '[file].map', null,
            "../../../ts/trm/[resource-path]", "../../../ts/trm/[resource-path]")
    ]
};

Is it possible to get a declaration output file?

ts-loader should ignore require() statements in definition (.d.ts) files

Some definition files, for example node.d.ts from DefinitelyTyped, contain named external modules, eg

declare module "events" { ... }

and then other named external modules that reference these modules with a require statement, eg

declare module "http" {
    import events = require("events");
    ...
}

Ts-loader then tries to resolve these modules through webpack, which it shouldn't be doing, because this is still all just metadata and they're not yet being used. It should only try to resolve them once a such a module is being require'd in a code (*.ts) file.

It causes the build to fail if those modules aren't available (which is the case for some of the node modules like 'events', 'net' etc.)

This makes it impossible to use node.d.ts in a project with ts-loader, but this problem isn't limited to that file; it can happen with any definition file that follows the same pattern.

Reproduction is easy with an app.ts file that just references a node.d.ts file:

/// <reference path="node.d.ts" />

and then a webpack.config.js file:

module.exports = {
    entry: './app.ts',
    output: {
        path: __dirname,
        filename: 'bundle.js',
    },
    resolve: {
        extensions: ['', '.webpack.js', '.web.js', '.js', '.ts']
    },
    module: {
        loaders: [
            { test: /\.ts$/, loader: 'ts-loader?sourceMap&target=ES5' }
        ]
    },
}

Loader option: ignoreWarnings

We need to add the loader option ignoreWarnings like typescript-simple-loader

One topic of discussion here is that ts-loader only emits TS errors as webpack errors and not warnings. Before we add this we need to decide between errors only vs errors/warnings, and if we go errors only then the option should probably be called ignoreErrors. Or we could sidestep the issue and come up with a more generic name.

Doesn't work with named external modules in d.ts files

I tried using ts-loader but immediately got this error:

Module build failed: Error: Cannot resolve module 'stream' in C:\...\typings\request
    at innerCallback (C:\...\node_modules\webpack\node_modules\enhanced-resolve\lib\Resolver
.js:80:16)
    at loggingCallbackWrapper (C:\...\node_modules\webpack\node_modules\enhanced-resolve\lib
\createInnerCallback.js:20:19)
    at C:\...\node_modules\webpack\node_modules\tapable\lib\Tapable.js:138:6
    at C:\...\node_modules\webpack\node_modules\enhanced-resolve\lib\ModulesInDirectoriesPlu
gin.js:53:23
    at C:\...\node_modules\webpack\node_modules\enhanced-resolve\lib\Resolver.js:210:15
    at C:\...\node_modules\webpack\node_modules\enhanced-resolve\lib\ModulesInDirectoriesPlu
gin.js:44:26
    at loggingCallbackWrapper (C:\...\node_modules\webpack\node_modules\enhanced-resolve\lib
\createInnerCallback.js:20:19)
    at C:\...\node_modules\webpack\node_modules\tapable\lib\Tapable.js:138:6
    at C:\...\node_modules\webpack\node_modules\enhanced-resolve\lib\Resolver.js:104:33
    at C:\...\node_modules\webpack\node_modules\enhanced-resolve\lib\Resolver.js:210:15

It can't resolve any named modules (declare module "somemodule" { ...) in node.d.ts or .d.ts files. Project compiles fine with tsc 1.4.1. Can provide a smaller example if needed.

(Also tried typescript-loader but it had this same problem)

Compiler Option: sourceMap

The loader current supports the sourceMap option. However, it needs to be manually specified in the tsconfig.json. I think that people can be confused by this because they think they can just turn on sourcemaps in webpack and everything should work. See #17 for example.

Would it make sense to automatically turn on the TS sourceMap option if we detect that sourcemaps are turned on by webpack? I don't like overriding the user though, so maybe only do this is sourceMap is omitted from tsconfig.json. If the user explicitly set sourceMap: false then we would not override.

Failing to resolve TypeScript library via NPM

I created a small sample library with a readme detailing the problem. ts-loader appears to have trouble finding a typescript module in the node_modules folder.

https://github.com/SonofNun15/typescript-library-test

The setup is pretty simple. A tiny TypeScript project is compiled and "deployed" as an npm package. Another small app installs this library as a dependency via npm and then tries to import using either the commonjs or ES6 syntax. Results in the following error:

ERROR in ./source/app.ts
Module not found: Error: Cannot resolve module 'library' in /Users/josh/Dev/ts-libraries/consumer/source
 @ ./source/app.ts 1:16-34

Perhaps I'm missing something obvious?

Lots of noise on ts errors

Hello,

Might be a more webpack related question but not 100%.
Just started looking at gulp+webpack+react+typescript (viewable at https://github.com/Keats/kcalculator-react) and when i get a ts compiler error, I also get the full 175 lines (one line per file loaded apparently) dumped in my console before the actual typescript error.

Did I miss an option to turn off that noise?
It does the same when I'm doing a build from gulp (errors are coming in the stats variable https://github.com/Keats/kcalculator-react/blob/master/gulpfile.js#L50).
Building through webpack CLI I get the error without the traceback, do you have any pointers?

Thanks for the loaders and the talk !

Umbrella: Evaluate all existing compiler options

There are a lot of TS compiler options. Some make sense with webpack, some don't. There have been pain points in the past where certain options cause issues (declaration, sourceMap, noLib, etc). So far these have been handled as reported on a case-by-case basis but I think it would be good to be proactive and evaluate all compiler options to make sure that the loader:

  1. Doesn't fail
  2. Possibly actively supports the option
  3. Possibly provides sane defaults

Here is an ongoing list of compiler options:

  • declaration
  • help
  • version
  • module
  • project
  • target
  • watch
  • charset
  • diagnostics
  • emitBOM
  • emitDecoratorMetadata
  • experimentalAsyncFunctions
  • inlineSourceMap
  • inlineSources
  • isolatedModules
  • jsx
  • listFiles
  • locale
  • mapRoot
  • moduleResolution
  • newLine
  • noEmit
  • noEmitOnError - #91
  • noEmitHelpers
  • noImplicitAny
  • noLib
  • noResolve
  • out
  • outDir
  • outFile
  • preserveConstEnums
  • removeComments
  • rootDir
  • sourceMap - #59
  • sourceRoot
  • stripInternal
  • suppressImplicitAnyIndexErrors

Move under TypeStrong

Would you be willing to move this under TypeStrong. That would:

a) help ensure continued support
b.) make more defacto (not that it isn't the case right now).

I'd be happy to add you as an owner under the org

webpack --watch not always detecting changes when you only change type information

When I run webpack --watch which uses ts-loader and ts-jsx-loader and I come across an typescript error, then sometimes when I change some TS code, the watcher does not trigger a new compilation run, and thus I don't see updated webpack output to tell me if the error is now solved.

I think it relates to Typescript specific changes that do not affect the JS output.
for example if I get this error:

Type 'SpecialType' is not assignable to type 'GeneralType'.

And I then change this:

var x:SpecialType = foo.getSomething()

to

var x:SpecialType = <SpecialType> foo.getSomething()

the watcher does not trigger a new compilation.
But if I remove the entire line it does (and ofcourse it shows me new errors because the line is missing).. then when I put the line back the watcher triggers again a new compilation and I finally see that my error is resolved.

So at the moment I often have to manually remove lines, save, and put them back, and save to trigger a compilation.
I'm not certain wether this is a bug of webpack or of ts-loader, but I'm expecting the ladder.

sourcemap contains js files

Hey, I'm using this together with your jsx-ts-loader plugin.
Also I need sourcemaps, and I used to use the 'sourceRoot' in the sourcemap file before.
I just read here how I can do that with webpack, and it's working, but now I see the content of my sourcefiles are actually the compiled js, not typescript. Any idea what I'm doing wrong or if this is a bug?
Here's my setup:

// webpack.config.js
var webpack = require('webpack');

module.exports = {
    entry: './init.ts',
    output: {
        filename: '../builds/html.bundle.js'
    },
    resolve: {
        extensions: ['', '.ts', '.webpack.js', '.web.js', '.js']
    },
    module: {
        loaders: [
            { test: /\.ts$/, loader: 'ts-loader!ts-jsx-loader' }
        ]
    },
    /*devtool: 'source-map',*/
    plugins: [
        new webpack.SourceMapDevToolPlugin(
            '[file].map', null,
            "../src/modules/html/[resource-path]", "../src/modules/html/[resource-path]")
    ]
};

and the abbriviated sourcemap file:

  "sources": [
    "../src/modules/html/webpack/bootstrap 1c9252c83a8886ca73cb",
    "../src/modules/html/./init.ts",
    "../src/modules/html/./src/UnsortedList.ts"
  ],
  "names": [],
  "mappings": ";AAAA;AACA;;AAEA;[...]ACA",
  "file": "../_builds/dacore.html.bundle.js",
  "sourcesContent": [
    "[..webpacksourcehere..]**/",
    "[..not_a_class_file...]",
    "[..here comes output from the TS compiler! --->] var  __extends = this.__extends || function (d, b) {\r\n    for (var p [.....]**/"
  ],
  "sourceRoot": ""

Problem with TSX

Hi, thanks for the great and updated ts-loader.
I seem to be struggling with the "*.tsx" files, for which I keed receiving following error:

ERROR in ../app/components/router.tsx
Module parse failed: /Users/tomi/Documents/Programming/Github/meteor-webpack-react/node_modules/ts-loader/index.js!/Users/tomi/Documents/Programming/Github/meteor-webpack-react/app/components/router.tsx Line 1: Unexpected token
You may need an appropriate loader to handle this file type.
| import { BlogHome } from './blog/blog';
| import ReactLayout from './react-layout';
| //console.log(BlogHome);
 @ ../app/main_client.js 15:0-30

This is my config:

resolve: {
    extensions: ['', '.js', '.jsx', '.ts', '.tsx' ],
    alias: {
      app: path.join(__dirname, '../app'),
    },
  },
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        loader: 'babel?stage=0',
        exclude: /node_modules|lib/,
      },
      {
        test: /\.css$/,
        loader: 'style-loader!css-loader'
      },
      {
        test: /(\.png|\.eot|\.svg|\.woff|\.ttf)/,
        loader: 'file'
      },
      // all files with a `.ts` or `.tsx` extension will be handled by `ts-loader`
      {
        test: /\.ts(x?)$/,
        loader: 'ts-loader'
      }
    ],

Typescript installed is 1.6.0 beta.

Would you know what the problem can be?
Thanks!

Update example to mention how to use require.ensure().

When using ts-loader working with ntypescript for tsx compilation, I ran into a bit of problem doing code-splitting. I got it working easily enough using import Home = require("./home") at the top of the file, but there is no code-splitting. When implementing code-splitting via require.ensure() like this:

  if (!location.hash || location.hash.length === 1) {
    require.ensure([], function () {
      var Home = require("./home");
      React.render(<Home/>, document.getElementById("app"));
    });
  }

I get errors. I can update to the any type:

      var Home = require<any>("./home");

But there is then no checking for props. After much experimentation, it seems this works:

import Home = require("./home");

at the top and then use typeof:

      var Home = require<typeof Home>("./home");

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.