Skip to content

Wrong output file location #123

Closed
Closed
@aradzie

Description

@aradzie

This is strange. I am pulling may hair out, cannot figure out what is wrong with my gulpfile. It contains two identical TS compile tasks, one produces a correct JS file, another does not.

The tasks are defined as follows:

gulp.task("typescript:app1", function () {
    return gulp.src(["./src/ts/app1.ts"])
            .pipe(plugin.sourcemaps.init())
            .pipe(plugin.typescript({
                out: "app1.js",
                target: "es6",
                module: "commonjs"
            }))
            .pipe(plugin.sourcemaps.write(".", {sourceRoot: "."}))
            .pipe(gulp.dest("./build"));
});

The only difference between tasks is that one takes app1.ts and produces app1.js. Another takes app2.ts and produces app2.js.

The project directory layout is as follows:

/home/user/project/gulpfile.js
/home/user/project/src/ts/app1.ts
/home/user/project/src/ts/app2.ts
/home/user/project/build

The first task produces a correct JS file:

/home/user/project/build/app1.js
/home/user/project/build/app1.js.map

However, the second task produces the following files:

/home/user/project/build/app2.js  <-- this one is empty
/home/user/project/build/app2.js.map
/home/user/project/build/home/user/project/src/ts/app2.js <-- this is a correct output file in a wrong directory
/home/user/project/build/home/user/project/src/ts/app2.js.map

Please note that the wrong directory is concatenation of the output directory and the source directory paths.

The problem goes away if I remove module option from the second task. E.g., remove the following line:

module: "commonjs"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions