standard-things / esm

Tomorrow's ECMAScript modules today!
Other
5.26k stars 146 forks source link

esm using gulp 4 webpack-stream setup not working #828

Open mylastore opened 5 years ago

mylastore commented 5 years ago

I implemented this per example using index.js pointing to main.js, also using gulp with webpack-stream and when it gets to gulp task scripts below

function scripts() {
    return gulp.src('./index.js')
        .pipe(gulpWebpack({
            entry: {
                'main-new': './index.js'
            },

I get this error

[13:03:21] Starting 'scripts'...
[13:03:21] 'scripts' errored after 178 ms
[13:03:21] Error in plugin "webpack-stream"
Message:
    ./node_modules/esm/esm.js
Module not found: Error: Can't resolve 'fs' in '/storage/projects/client/node_modules/esm'
resolve 'fs' in '/storage/projects/client/node_modules/esm'
  Parsed request is a module
  using description file: /storage/projects/client/node_modules/esm/package.json (relative path: .)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /storage/projects/client/node_modules/esm/package.json (relative path: .)
    resolve as module
      looking for modules in /storage/projects/client/src/js
        using description file: /storage/projects/client/package.json (relative path: ./src/js)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /storage/projects/client/package.json (relative path: ./src/js)
          using description file: /storage/projects/client/package.json (relative path: ./src/js/fs)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /storage/projects/client/src/js/fs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /storage/projects/client/src/js/fs.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              /storage/projects/client/src/js/fs.json doesn't exist
            .ejs
              Field 'browser' doesn't contain a valid alias configuration
              /storage/projects/client/src/js/fs.ejs doesn't exist
            as directory
              /storage/projects/client/src/js/fs doesn't exist
      looking for modules in /storage/projects/client/node_modules
        using description file: /storage/projects/client/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /storage/projects/client/package.json (relative path: ./node_modules)
          using description file: /storage/projects/client/package.json (relative path: ./node_modules/fs)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /storage/projects/client/node_modules/fs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /storage/projects/client/node_modules/fs.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              /storage/projects/client/node_modules/fs.json doesn't exist
            .ejs
              Field 'browser' doesn't contain a valid alias configuration
              /storage/projects/client/node_modules/fs.ejs doesn't exist
            as directory
              /storage/projects/client/node_modules/fs doesn't exist
[/storage/projects/client/src/js/fs]
[/storage/projects/client/src/js/fs.js]
[/storage/projects/client/src/js/fs.json]
[/storage/projects/client/src/js/fs.ejs]
[/storage/projects/client/src/js/fs]
[/storage/projects/client/node_modules/fs]
[/storage/projects/client/node_modules/fs.js]
[/storage/projects/client/node_modules/fs.json]
[/storage/projects/client/node_modules/fs.ejs]
[/storage/projects/client/node_modules/fs]
 @ ./node_modules/esm/esm.js 1:512-525
 @ ./index.js./node_modules/esm/esm.js
mylastore commented 5 years ago

I figure out why just corrected my gulp pipe entry src I was pointing both gulp src and entry src to index.js that contains the esm module.

function scripts() {
    return gulp.src('./index.js')
        .pipe(gulpWebpack({
            entry: {
                'main-new': './src/js/main.js'
            },