Skip to content

Dynamic import support for Gulp #10

@ajmeese7

Description

@ajmeese7

The following does not work when trying to run any Gulp tasks:

import read from "fs-readdir-recursive";

/**
 * This will load all js in the gulp directory
 */
read("./gulp")
  .filter(function (file) {
    console.log(file);
    return /\.(js)$/i.test(file);
  })
  .map(async function (file) {
    await import("./gulp/" + file);
  });

When using the require syntax the code works fine:

const read = require("fs-readdir-recursive");

/**
 *  This will load all js in the gulp directory
 */
read("./gulp")
  .filter(function (file) {
    console.log(file);
    return /\.(js)$/i.test(file);
  })
  .map(function (file) {
    require("./gulp/" + file);
  });

The ESM syntax is the problem. Would love to see support added for this! In the meantime I'll have to manually import each file from the gulp directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions