Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work with typescript 1.5-beta #14

Closed
Ciantic opened this issue May 5, 2015 · 15 comments
Closed

Does not work with typescript 1.5-beta #14

Ciantic opened this issue May 5, 2015 · 15 comments

Comments

@Ciantic
Copy link

Ciantic commented May 5, 2015

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.

@jbrantly
Copy link
Member

jbrantly commented May 5, 2015

There is a typescript-1.5 branch where I've done most of the work to get stuff working with TS 1.5. I need to do an NPM push but just haven't gotten to it yet. The only thing left is ts.config support. I'll try to get it out soon.

I'm not sure why ts-jsx-loader wouldn't work with another TS loader. There's nothing special ts-loader does with regards to ts-jsx-loader (or vice-versa).

@Ciantic
Copy link
Author

Ciantic commented May 6, 2015

I tried your TS1.5 branch.

This seems to have similar "File not found" errors in Windows as the other loader with TS 1.5.

C:\Projects\HTML5\model-validation-ghpages\src>webpack
Using config file at C:\Projects\HTML5\model-validation-ghpages\src\tsconfig.json
ERROR
  unknown file: File 'C:/Projects/HTML5/model-validation-ghpages/src/index.ts' not found.
ERROR
  unknown file: File 'C:/Projects/HTML5/model-validation-ghpages/src/references.d.ts' not found.
ERROR
  ...

yet, index.ts is there

cat C:/Projects/HTML5/model-validation-ghpages/src/index.ts

Contents

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

//require('./styles.less');
import * as React from 'react';

interface App {

}
class AppComponent extends React.Component<{}, App> {
    render() {
        React.jsx(`
            <x-model-validation-ghpages>
                <div>
                    test
                </div>
            </x-model-validation-ghpages>
        `)
    }
}
function main() {
    /*React.render(React.jsx(`<Application products={products} someInt="test" />`),
        document.body);*/
}

main();

@jbrantly
Copy link
Member

jbrantly commented May 6, 2015

I just published v0.4.0. I didn't see your message here until after I published. It seems there might be a bug somewhere with Windows? I'll take a look.

@Ciantic
Copy link
Author

Ciantic commented May 6, 2015

Yes, I can confirm the false "File not found" errors persist in the v0.4.0 (current master).

@Ciantic
Copy link
Author

Ciantic commented May 6, 2015

Btw, you might want to look this s-panferov/awesome-typescript-loader#9 — I fixed it in that plugin at the last message, simply changing "" to "/", but with this plugin they are already "/" so I'm not sure what is the problem yet.

@jbrantly
Copy link
Member

jbrantly commented May 6, 2015

I just tried a medium-sized TypeScript app I have on a Windows machine and it compiled fine. It's similar to your app in certain ways (using forward slashes for require() paths). Would it be possible to put an entire working example up on GitHub somewhere?

@Ciantic
Copy link
Author

Ciantic commented May 6, 2015

Yes I'll put it up shortly, but it has something to do with tsconfig.json file, if I rename it, it starts to work again.

@jbrantly
Copy link
Member

jbrantly commented May 6, 2015

Just guessing here, but I have something you could try. Try adding fileName = path.normalize(fileName) between lines 127 and 128. https://github.com/jbrantly/ts-loader/blob/master/index.ts#L127-L128

If that still doesn't work, additionally add it here: https://github.com/jbrantly/ts-loader/blob/master/index.ts#L127-L128

@jbrantly
Copy link
Member

jbrantly commented May 6, 2015

Whoops, that second location was supposed to be here: https://github.com/jbrantly/ts-loader/blob/master/index.ts#L137-L138

@Ciantic
Copy link
Author

Ciantic commented May 6, 2015

It actually comes with simplest example:

webpack.config.js

module.exports = {
    resolve: {
        extensions: ['', '.ts', '.js']
    },
    devtool: 'source-map',
    module: {
        loaders: [{
            test: /\.ts$/,
            loader: 'ts-loader?sourceMap'
        }]
    },
    entry: {
        index: ['./index.ts']
    },
    output: {
        path: 'build/',
        filename: '[name].js'
    }
};

and

index.ts

function main() {

}

main();

tsconfig.json

{
    "version": "1.5.0-beta",
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "declaration": false,
        "noImplicitAny": false,
        "removeComments": true,
        "noLib": false
    },
    "filesGlob": [
        "./**/*.ts",
        "!./node_modules/**/*.ts"
    ],
    "files": [
        "./index.ts"
    ]
}

@Ciantic
Copy link
Author

Ciantic commented May 6, 2015

Hey, that worked.

fileName = path.normalize(fileName)

@jbrantly
Copy link
Member

jbrantly commented May 6, 2015

Which location? Just the first or both?

@Ciantic
Copy link
Author

Ciantic commented May 6, 2015

getScriptVersion: function (fileName) { return files[fileName] && files[fileName].version.toString(); },
        getScriptSnapshot: function (fileName) {
            fileName = path.normalize(fileName);
            var file = files[fileName];
            if (!file)
                return undefined;
            return compiler.ScriptSnapshot.fromString(file.text);
        },

Directly in the js file

Only that position

@Ciantic
Copy link
Author

Ciantic commented May 6, 2015

Now I tried with a larger project, it still gives a some unnormalized error:

C:\Projects\HTML5\model-validation-ghpages\src>webpack
Using config file at C:\Projects\HTML5\model-validation-ghpages\src\tsconfig.json
C:\Projects\HTML5\model-validation-ghpages\src\node_modules\ts-loader\node_modules\typescript\bin\typescript.js:36248
                throw new Error("Could not find file: '" + fileName + "'.");
                      ^
Error: Could not find file: 'C:/Projects/HTML5/model-validation-ghpages/src/./references.d.ts'.

Maybe it's required in two places. I'm also in here: https://gitter.im/TypeStrong/atom-typescript lot's of other typescript peeps there.

@jbrantly
Copy link
Member

jbrantly commented May 9, 2015

All of the issues brought up in this issue are now resolved as of v0.4.2 which has been published to NPM.

@jbrantly jbrantly closed this as completed May 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants