rollup-plugin-auto-external icon indicating copy to clipboard operation
rollup-plugin-auto-external copied to clipboard

Exclude specific builtins as an external

Open DrSensor opened this issue 6 years ago • 4 comments

I wonder if I can exclude specific builtins as an external to support shimming. For example:

plugins: [
  autoExternal({
    builtins: {
      include: '*'
      exclude: ['readline']
    }
  }),
  shim({
    readline: "export default {createInterface(){}}"
  })
]

For more granular control:

plugins: [
  autoExternal({
    builtins: {
      include: '*'
+     exclude: {
+	     '@npm/module1': ['readline']
+     }
    }
  }),
  shim({
    readline: "export default {createInterface(){}}"
  })
]

DrSensor avatar Dec 17 '18 03:12 DrSensor

I'll see if I can make this work. Thanks for the suggestion 😄

stevenbenisek avatar Feb 25 '19 15:02 stevenbenisek

Untill then, this should work:

import autoExternal from 'rollup-plugin-auto-external';
import shim from 'rollup-plugin-shim';
import builtins from 'builtins';

export default {
  input: 'index.js',
  external: builtins().filter(id => id !== 'readline'),
  plugins: [
    autoExternal({
      builtins: false
    }),
    shim({
      readline: "export default {createInterface(){}}"
    })
  ]
};

stevenbenisek avatar Feb 28 '19 17:02 stevenbenisek

I'm thinking about moving the external option to the root of the options object. I don't think this has to be limited to builtins. What do you think @DrSensor?

plugins: [
  autoExternal({
    exclude: ['readline']
  }),
  shim({
    readline: "export default {createInterface(){}}"
  })
]

stevenbenisek avatar Mar 11 '19 21:03 stevenbenisek

For more granular control:

Care to elaborate about this @DrSensor? Do you have a specific use case in mind?

stevenbenisek avatar Mar 11 '19 21:03 stevenbenisek