Giter Site home page Giter Site logo

Comments (3)

k-maru avatar k-maru commented on June 19, 2024

I can not reproduce the error.
Please show the code to reproduce.

or

grunt --verbose option log

e.g. grunt typescript --verbose

from grunt-typescript.

Coridyn avatar Coridyn commented on June 19, 2024

I've just found this error too. The TypeScript compiler is writing all source files out multiple times (so for 100 input files it will write out 100 * 100 = 10,000 files).

Here is an example project showing the problem: https://github.com/Coridyn/grunt-typescript-debug

Expected output:

--host.writeFile: src/app.js
  write file: src/app.js => l:/User/projects/WidgetWorks/wiwo-playground/grunt-typescript-debug/dist/app.js
--host.writeFile: src/other-file.js
  write file: src/other-file.js => l:/User/projects/WidgetWorks/wiwo-playground/grunt-typescript-debug/dist/other-file.js
2 files created. js: 2 files, map: 0 files, declaration: 0 files

Actual output:

--host.writeFile: src/app.js
  write file: src/app.js => l:/User/projects/WidgetWorks/wiwo-playground/grunt-typescript-debug/dist/app.js
--host.writeFile: src/other-file.js
  write file: src/other-file.js => l:/User/projects/WidgetWorks/wiwo-playground/grunt-typescript-debug/dist/other-file.js
--host.writeFile: src/app.js
  write file: src/app.js => l:/User/projects/WidgetWorks/wiwo-playground/grunt-typescript-debug/dist/app.js
--host.writeFile: src/other-file.js
  write file: src/other-file.js => l:/User/projects/WidgetWorks/wiwo-playground/grunt-typescript-debug/dist/other-file.js
--host.writeFile: src/app.js
  write file: src/app.js => l:/User/projects/WidgetWorks/wiwo-playground/grunt-typescript-debug/dist/app.js
--host.writeFile: src/other-file.js
  write file: src/other-file.js => l:/User/projects/WidgetWorks/wiwo-playground/grunt-typescript-debug/dist/other-file.js
6 files created. js: 6 files, map: 0 files, declaration: 0 files (492ms)

It looks like typescript.js compile() function (https://github.com/k-maru/grunt-typescript/blob/master/tasks/typescript.js#L738) calls checker.emitFiles() for every file.

program.getSourceFiles().forEach(function (sourceFile) {
    if (!options.noLib && sourceFile.filename === defaultLibFilename) {
        return;
    }
    var emitOutput = checker.emitFiles(sourceFile);
    errors.push.apply(errors, emitOutput.errors);
});

and tsc.js emitFiles() (https://github.com/Microsoft/TypeScript/blob/v1.1.0.1/bin/tsc.js#L8496) calls emitFile() for every file as well

ts.forEach(program.getSourceFiles(), function (sourceFile) {
    if (shouldEmitToOwnFile(sourceFile)) {
        var jsFilePath = getOwnEmitOutputFilePath(sourceFile, ".js");
        emitFile(jsFilePath, sourceFile);
    }
});

from grunt-typescript.

k-maru avatar k-maru commented on June 19, 2024

Thanks Coridyn.

It seems that my reading was not enough.
I has released a modified version 0.4.3

from grunt-typescript.

Related Issues (20)

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.