gulp-community / gulp-concat

Streaming concat middleware for gulp
MIT License
792 stars 126 forks source link

Error: "Identifier 'globalVar' has already been declared" when using JS modules #148

Closed ondrej-merkun closed 5 years ago

ondrej-merkun commented 5 years ago

File1.js code:

export const globalVar = "lol";

File2.js code:

import { globalVar } from "./File1.js"

Gulpfile.js code:

const gulp = require("gulp");
const babel = require("gulp-babel");
const concat = require('gulp-concat');

gulp.task("default", function () {
  return gulp.src("src/js/*.js")
    .pipe(concat('scripts.js'))
    .pipe(babel())
    .pipe(gulp.dest("dist/js"));
});
ondrej-merkun commented 5 years ago

Turns out this is natural behavior of files that are concatenated.