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

importing gulpfile.babel.js into another gulpfile.babel.js throws ES6 error #202

Open
nebrekab opened this issue Jun 27, 2020 · 0 comments

Comments

@nebrekab
Copy link

nebrekab commented Jun 27, 2020

I am trying to run a parent folder (global) gulpfile.babel.js within a sub folder gulpfile.babel.js and have run in to an error:

export default function(gulp, config) {
^^^^^^

SyntaxError: Unexpected token 'export'

Code is:

// parent gulpfile.babel.js
export default function(gulp, config) {
  return gulp;
}
// child gulpfile.babel.js
import {config} from './gulp.config.js';
import gulp from 'gulp';
import globalTask from '../gulpfile.babel.js';
globalTask(gulp, config);

// project-specific tasks using gulp and config goes here

export const setup = (done) => {
    console.log(`Activity tasks for ${config.name}`);
    done();
}

export default setup;
// package.json (in parent)
{
  "name": "activity-base",
  "version": "0.0.1",
  "description": "Activity base.",
  "scripts": {
    "start": "gulp",
    "prod": "gulp build --prod"
  },
  "author": "Neb",
  "license": "ISC",
  "devDependencies": {
    "@babel/core": "^7.9.6",
    "@babel/preset-env": "^7.9.6",
    "@babel/register": "^7.9.0",
    "babel-loader": "^8.1.0",
    "del": "^5.1.0",
    "gulp": "^4.0.2",
    "gulp-if": "^3.0.0",
    "webpack": "^4.43.0",
    "webpack-stream": "^5.2.1",
    "yargs": "^15.3.1"
  },
  "dependencies": {},
  "babel": {
    "presets": [
      "@babel/preset-env"
    ]
  }
}

If I change the parent gulpfile.babel.js to ES5 code it runs fine:

// parent gulpfile.babel.js
module.exports = function(gulp, config) {
  // project-independent stuff using gulp and config goes here
  console.log(`Do project-wide tasks for the ${config.name}`);
  return gulp;
};

Any ideas what's going on and how to fix?

Thanks in advance :)

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

1 participant