Fix ERR_UNSUPPORTED_DIR_IMPORT for gulpfile.mjs#217
Fix ERR_UNSUPPORTED_DIR_IMPORT for gulpfile.mjs#217ngdangtu-vn wants to merge 3 commits intogulpjs:masterfrom
Conversation
Import directory testcase mentioned above:(a) My testcase was simple, I create an // repo structure
/
.d/
src/
gulpfile.mjs/
index.mjs
a/
files.txt
b/
x.conf
c.txt// gulpfile.mjs/index.mjs file
import gulp from 'gulp'
import path from 'path'
const dir = [
path.join('..', 'a'),
path.join('..', 'b/*.conf'),
path.join('..', 'c.txt')
]
const dest = '../.d/'
export function copy() {
return gulp.src(dir, { base: '..' })
.pipe(gulp.dest(dest))
}
export default gulp.series(copy)From |
|
One small problem appeared. If users set
On the bright side, if this PR gets refused. We can still organize |
|
@ngdangtu-vn Does this change the behavior people expect from the import syntax in node? I don't really want to define our own behavior for that. |
Yes and no:
Therefore, this patch is still safely to merge. |
|
@ngdangtu-vn I believe this needs conflicts resolved since I merged #239 |
|
@phated It has been too long so I don't really remember what I did back then :)) I can resolve this but do we really need this PR anymore? |
|
That's fine. I wasn't sure I wanted to include this so we can just close it out. |
What is this PR for?
This is a ERR_UNSUPPORTED_DIR_IMPORT fixed patch. (And did a bit code refactor in
require-or-import.jsfile)Before this patch, gulp-cli won't be able to read directory URL for ESM mode. For example:
The only solution is append
index.mjsto the directory. And I fixed it.Was it tested yet?
Almost everything.
gulpfile.mjsdirectory -> Tested directly in my own repo (a)gulpfile.mjsdirectory -> I have no idea how to do it, so this task is under researchingIf it possible, I would like to merge this patch to gulp-cli.