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

3.2 breaks build #525

Closed
klmdb opened this issue Jul 7, 2017 · 13 comments
Closed

3.2 breaks build #525

klmdb opened this issue Jul 7, 2017 · 13 comments

Comments

@klmdb
Copy link

klmdb commented Jul 7, 2017

This morning our build was broken due to the 3.2 release of gulp-typescript. Setting the version to ~3.1.0 fixed the build. These were the errors I was getting:

2017-07-07T06:14:43.9933786Z public\app\core\authentication\authentication.spec.ts(5,18): error TS2304: Cannot find name 'AuthenticationService'.
2017-07-07T06:14:43.9933786Z public\app\core\authentication\authorization.api.spec.ts(5,18): error TS2304: Cannot find name 'AuthorizationApiService'.
2017-07-07T06:14:43.9933786Z public\app\core\authentication\authorization.spec.ts(5,18): error TS2304: Cannot find name 'AuthorizationService'.
2017-07-07T06:14:43.9933786Z public\app\core\language\language.api.spec.ts(5,18): error TS2304: Cannot find name 'LanguageApiService'.
2017-07-07T06:14:43.9933786Z public\app\core\language\language.spec.ts(5,18): error TS2304: Cannot find name 'LanguageService'.
...
2017-07-07T06:14:44.1808542Z [08:14:44] TypeScript: 16 semantic errors
2017-07-07T06:14:44.1808542Z [08:14:44] TypeScript: emit succeeded (with errors)

Is there a changelog available where I can check what may have cause the difference in behavior please?

Next are my gulpfile.js and tsconfig.json Maybe some tsconfig settings have changed behavior? Judging from the error output I'd guess it may be related to the including of type files.

Your gulpfile:

var tsProjectSpecs = ts.createProject(`${config.configDir}/tsconfig.spec.json`, {
    outFile: config.testing.js.src.name,
});

var buildSpecs = function (haltOnError) {

    // build specs typescript to javascript
    // --------------------------------------
    var tsResult = tsProjectSpecs.src()
        .pipe(gulpIf(config.enableSourceMaps, sourcemaps.init()))
        .pipe(tsProjectSpecs())

        .once('error', function () {
            if (haltOnError) {
                this.once('finish', () => process.exit(1));
            }
        })
        ;

    return tsResult.js

        // annotate
        .pipe(ngAnnotate())

        .pipe(gulpIf(config.enableSourceMaps, sourcemaps.write('.')))
        .pipe(gulp.dest(config.testing.outDir))
        .pipe(browserSync.stream())
};

tsconfig.json

{
  "compilerOptions": {
    "module": "none",
    "target": "es5",
    "removeComments": false,
    "sourceMap": true,
    "inlineSources": true,
    "outFile": "../.build/testing/specs_src.js",
    "declaration": false,

    "noFallthroughCasesInSwitch": true,
    "noImplicitUseStrict": true,
    "noImplicitThis": false,
    "noUnusedLocals": true,
    "noUnusedParameters": false,
    "strictNullChecks": false,
    "noImplicitReturns": false,
    "noImplicitAny": false,

    "rootDir": ".",
    "typeRoots": [
      "../typings",
      "../node_modules/@types"
    ],
    "types": [
      "jasmine",
      "ng-describe"
    ]
  },
  "include": [    
    "../test/mocks/*.ts",
    "../test/helpers/*.ts",
    "../public/app/**/*.spec.ts",
    "../test/**/*.spec.ts",

    "../typings/**/*",
    "../.build/app/app_src.d.ts"
  ]
}
@ivogabe
Copy link
Owner

ivogabe commented Jul 7, 2017

The latest release adds support for the extends field in tsconfig files, I suspect that the change in reading tsconfig files might have broken some functionality of tsProject.src(). I'll need to take a proper look at that to be sure. Could you share your project? You may also mail it privately to me, if needed with NDA.

@klmdb
Copy link
Author

klmdb commented Jul 10, 2017

I cannot.

From the output, I suspect something might have changed in the way ts file include/exclude of type files is handled. Can you say if any of this behavior may have been touched?

@bulldetektor
Copy link

We have troubles with the 3.2 version as well. Not sure if it's related, but gulp-typescript now suddenly spits out the following error messages;
[gulp-typescript] 2688 Cannot find type definition file for 'jquery'.
[gulp-typescript] 2688 Cannot find type definition file for 'mocha'.

Downgraded to version 3.1.7 and everything works again.

@AHelper
Copy link

AHelper commented Jul 11, 2017

Hey, I also just started getting this and worked around it on our end.

As part of our gulp build process, we copy & generate files (*.ts, *.d.ts) that get consumed by our TS codebase. Now, we were doing tsProject = gulpTypescript.createProject("tsconfig.json", { rootDir : "./" }); before those files finished copying/generating. Dumping files picked up on tsProject.src() showed it missed those files whereas in 3.1.7 it would pick those up. Creating the project object after everything settles lets it pick up the files. I'm guessing the project now scans for files as soon as it is created rather than deferring.

Not sure if this is what anyone else here is having happen to them, but thought I'd share in case it helps 😄

ivogabe added a commit that referenced this issue Jul 11, 2017
@ivogabe
Copy link
Owner

ivogabe commented Jul 11, 2017

@AHelper thanks, I could find the cause for that and I think that it is fixed in c0bbd46.

To all: could you try installing gulp-typescript from GitHub? I think that this will fix your issues, but let me know if you're still experiencing trouble.

@klmdb
Copy link
Author

klmdb commented Jul 12, 2017

@AHelper we also generate a .d.ts file for our project ("../.build/app/app_src.d.ts"), that is then consumed by our test build. And, our ts.createProject() is called at the start of our gulpfile.

@ivogabe because of the similarity to the case described by @AHelper, I just tried installing the package from github by setting my package.json and installing with nmp install:
"gulp-typescript": "https://github.com/ivogabe/gulp-typescript.git",

I still get the same errors, though. And, when I move the ts.createProject() so that the project is initiated after the typing files have been created, it does not change the outcome.

@ivogabe
Copy link
Owner

ivogabe commented Jul 14, 2017

And, when I move the ts.createProject() so that the project is initiated after the typing files have been created, it does not change the outcome.

@klmdb Then you might have a different issue than @AHelper. Could you use gulp-debug to see which files are missing when using gulp-typescript 3.2?

@AHelper and @bulldetektor: Could you try to install gulp-typescript from GitHub and run it on your project? You can simply copy the release folder and put it in node_modules/gulp-typescript/release

@AHelper
Copy link

AHelper commented Jul 14, 2017

@ivogabe That fixes it for me

@ivogabe
Copy link
Owner

ivogabe commented Jul 15, 2017

The changes are included in the new release, 3.2.1. Can you all install this release and see whether it solves your issues?

@klmdb
Copy link
Author

klmdb commented Aug 21, 2017

@ivogabe doesn't seem to fix the issue for me.

I compile my source in two steps: first the full application, then the tests. building the app works fine, but building the tests fails as described.

I just noticed, however, that the application bundle isn't build to the correct folder. Instead of .build/app, it now ends up in .build. This explains why the test build fails.

So, it seems that 3.2.x changes the destination of the build file.

Some more info:

  • tsconfigs location: config/tsconfig.app.json & config/tsconfig.spec.json
  • outfiles: app_src.js & specs_src.js
  • gulpfile ts build function:
    var tsProjectApp = ts.createProject(`config/tsconfig.app.json`, {
        outFile: 'app_src.js'
    });
    
    var buildJs = function (haltOnError) {
    
        // build app typescript to javascript
        // --------------------------------------
        var tsResult = tsProjectApp.src()
            .pipe(gulpIf(config.enableSourceMaps, sourcemaps.init()))
            .pipe(tsProjectApp())
    
            .once('error', function () {
                if (haltOnError) {
                    this.once('finish', () => process.exit(1));
                }
            })
            ;
    
        return merge([
    
            // js
            tsResult.js
                // .pipe(rename('app_src.js'))
                .pipe(gulpIf(config.enableSourceMaps, sourcemaps.write('.')))
                .pipe(print())
                .pipe(gulp.dest('.build/app')),
    
            // d.ts
            tsResult.dts
                // .pipe(rename('app_src.d.ts'))
                .pipe(print())
                .pipe(gulp.dest('.build/app'))
    
        ])
            ;
    };
  • output with 3.1.x:
    [09:54:38] Starting 'build:js'...
    [09:54:43] config\app_src.js.map
    [09:54:43] config\app_src.js
    [09:54:43] config\app_src.d.ts
    [09:54:43] Finished 'build:js' after 5.15 s
    
    • file ends up in .build/app
  • output with 3.2.x:
    [09:48:40] Starting 'build:js'...
    [09:48:45] app_src.js.map
    [09:48:45] app_src.js
    [09:48:45] app_src.d.ts
    [09:48:45] Finished 'build:js' after 5.49 s
    
    • file ends up in .build
  • output with 3.2.x with rename:
    [09:52:03] Starting 'build:js'...
    [09:52:08] config\app_src.js.map
    [09:52:08] config\app_src.js
    [09:52:08] config\app_src.d.ts
    [09:52:08] Finished 'build:js' after 5.13 s
    
    • file ends up in .build/app

@klmdb
Copy link
Author

klmdb commented Sep 14, 2017

bump?

@ivogabe
Copy link
Owner

ivogabe commented Sep 20, 2017

I guess that something fails when a tsconfig file is placed in a subdirectory, but I didn't have time to take a proper look at it.

@ivogabe
Copy link
Owner

ivogabe commented Jan 10, 2018

The fix is part of the latest (pre)release. You can install it with npm install [email protected]

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

4 participants