rollup / rollup-plugin-commonjs

This module has moved and is now available at @rollup/plugin-commonjs / https://github.com/rollup/plugins/blob/master/packages/commonjs
MIT License
502 stars 126 forks source link

Couldn't external cjs when using another plugin with resolveId() returns false #343

Closed clark-t closed 4 years ago

clark-t commented 6 years ago

It's quite easy to reproduce.

the entry file is a.js:

var b = require('./b')
console.log(b)

the dependency file is b.js:

module.exports = 'b'

I wanna external b.js so I create a simple plugin with resolveId:

// rollup-plugin-external.js
module.exports = function () {
  return {
    resolveId (importee, importer) {
      if (!/^\0/.test(importee) && /b(\.js)?$/.test(importee)) {
        return false
      }
    }
  }
}

and the rollup.config.js is simple

var commonjs = require('rollup-plugin-commonjs')
var external = require('./external')

module.exports = {
  input: 'a.js',
  plugins: [
    external(),
    commonjs()
  ],
  output: {
    file: 'bundle.js',
    format: 'amd'
  }
}

when running rollup -c, no file is generated. but if a.js and b.js are es modules, the output file bundle.js would be generated as expected.

shellscape commented 4 years ago

Hey folks (this is a canned reply, but we mean it!). Thanks to everyone who participated in this issue. We're getting ready to move this plugin to a new home at https://github.com/rollup/plugins, and we have to do some spring cleaning of the issues to make that happen. We're going to close this one, but it doesn't mean that it's not still valid. We've got some time yet before the move while we resolve pending Pull Requests, so if this issue is still relevant, please @ me and I'll make sure it gets transferred to the new repo. :beer: