standard-things / esm

Tomorrow's ECMAScript modules today!
Other
5.27k stars 147 forks source link

Does it work with gulp 4? #826

Closed mylastore closed 5 years ago

mylastore commented 5 years ago

I am using gulp 4 with a task that run my main.js, I added the esm via the index.js configuration example and pointing to the main.js but when I run gulp Is complaining that I need to install @babel/register or babel-register plus it also does not recognize import statements and I am sure at this point esm is not loaded, also try this on package.json nodemon -r esm gulp but get this

[nodemon] starting `node -r esm ./gulp index.js`
Error: Cannot find module '/storage/projects/client/gulp'
jdalton commented 5 years ago

Hi @mylastore!

If you can produce a simple repro repo I'll try to spot the issue for ya :)

mylastore commented 5 years ago

@jdalton Thanks for the quick response I have this project hope you can test it here by simply running npm start that is where I added esm like this "start": "node -r esm gulp", https://github.com/mylastore/nodeshop

jdalton commented 5 years ago

I don't see esm in use in nodeshop. Would you please create a branch with what you're trying to do?

mylastore commented 5 years ago

OOPS forgot to push, just push the new package.json

jdalton commented 5 years ago

Now I get

Error: Cannot find module '/Users/johndavid.dalton/projects/nodeshop/gulp'

mylastore commented 5 years ago

just push package.json again added another esm as a starting script so is not confusing.

exactly that's what I get to. If you run npm run gulp that works but if you run npm run esm does not work and get cannot find module '../../gulp'

 "scripts": {
    "start": "gulp",
    "esm": "node -r esm gulp",
    "gulp": "gulp",
jdalton commented 5 years ago

That is because npm does some behind the scenes magic to resolve the local bin of gulp since it's a dep. When you explicitly call node you have to provide it a proper path.

node -r esm ./node_modules/gulp/bin/gulp.js

mylastore commented 5 years ago

ah good to know wow thank you for your time and this awesome project