lemmabit / rollup-plugin-hypothetical

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

Support to define external modules as hypothetical #4

Closed nkzawa closed 7 years ago

nkzawa commented 7 years ago

I'm not sure if this is acceptable since it would be a breaking change.

hypothetical({
  files: {
    "foo/bar.js": ""
  }
})

The above setting is used to be treated as a relative file but this PR makes it an external module file.

lemmabit commented 7 years ago

Ahh, interesting. I should have thought of this when I made the plugin.

There are a few ways this sort of thing can be achieved right now, but they're all pretty awful. I can think of some non-breaking changes that would make it easier, but your solution is pretty obviously the one that makes the most sense. This package doesn't seem to have too many dependents, so I think a breaking change will be okay.

I don't have much time to work on stuff like this at the moment, so thank you for the PR! The allowExternalModules option will require some rethinking. I don't think it makes much sense to give the user an option that makes some of the files they passed in unreachable. On the other hand, if it didn't affect passed-in files, I'm not sure the current name would make sense.

I'll hopefully be able to get around to this soon. I'll think about it in the meantime.

lemmabit commented 7 years ago

Sorry I took so long, and thanks again for the quality PR. That being said, I did have to bolt a bunch of stuff onto it before I could be satisfied that it was ready for v2.0.0. Lots of new edge cases.

lemmabit commented 7 years ago

Published as v2.0.0.