New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugin support for modifying external dependency references #350
Comments
@icambron Now I see what you're getting at! You want to make the generated external module id something different from that in the sources? |
@Victorystick correct! Sorry I didn't make that clear. |
As I see it there's two possible approaches:
Thoughts welcome! |
I'm in favor of 1. I think 2 is way too brittle and it just seems icky to operate on the text directly like that. I suspect this is not an unusual case. I'm not doing anything weird at all; I'm just trying to allow some tests to consume my module. Hard not to conclude this is going to come up a lot. |
Sorry for the loooooong delay in responding. For anyone who ends up here: we actually ended up implementing both 1 and 2:
|
Woo, thanks! |
please update links |
As a matter of fact I have just prepared a PR that will give you another option, much closer to what was originally proposed: #2734 The reason I implemented it was because I needed an object form of |
About the missing links, this is the
|
https://rollupjs.org/configuration-options/#output-paths Is it possible to config output-paths to dynamic paths? like this
|
I believe this is a feature request, but if there's a way to do it now, I'd love to know about it. I'm happy to do the work here if a PR would be accepted, but I'd appreciate any pointers on how/where to do it. Here's my scenario:
I have some tests written in ES6 and broken down into ES6 modules. They reference my library because they're testing it, so like:
For the sake of the example, let's say I'm compiling this to CJS-style modules so that I can run the tests in Node. My library code is rolled up and babeled to, say,
[project root]/dist/cjs/mylib.js
. AFAIK, I have these choices:1 is what I do now using a
resolveId()
plugin to track down the library code in thedist
dir, and it's not ideal; I'd like my tests to reference my library externally. 2. doesn't work because it builds in arequire()
call that can't actually be satisfied; my library's code is built to a subdirectory, not installed intonode_modules
. 3 is gross and brittle, because I have to go change a zillion imports if I change where stuff goes.So what I'd like to have is another plugin entry point that let's me rewrite the unresolved external dependency, so turning
into
I propose it looks something like this:
and that's what gets stuffed into the
require
(or AMDdefine
or ES6import
or whatever). Does this make sense as a proposal? Is it a good idea?The text was updated successfully, but these errors were encountered: