lemmabit / rollup-plugin-hypothetical

gives Rollup an imaginary file system, e.g. for testing other plugins
MIT License
44 stars 14 forks source link

The plugin removes the module code, but leaves the import in the bundle #14

Open haydentech opened 1 year ago

haydentech commented 1 year ago

My goal is remove certain node modules from the output entirely - no bundling and no imports. The reason I want to remove them from the bundle is that I need to bring them in via a script tag instead.

I am able to get the plugin to remove the module code from the bundle, using the config below, but the imports in the js bundle remain and cause things not to work in the browser. Is there a setting in the plugin to also remove the imports?

// vite.config.js

import hypothetical from 'rollup-plugin-hypothetical';

export default {
    build: {
        rollupOptions: {
            external: ['masonry-layout', 'typeahead-standalone', 'video.js']
        }
    },
    plugins: [hypothetical({
        allowFallthrough: true,
        files: {
          'typeahead-standalone/': ``,
          'masonry-layout/': ``,
          'video.js/': ``
        }
      })]
}

Undesired output in bundle:

import X from"masonry-layout";import ee from"video.js";import fe from"typeahead-standalone";