Stylus @import resolution: does the resolve callback override the paths option?
0 reputation · 10 Nov 2020, 05:39 UTC
Stylus 0.64.x resolves @import and @require by checking the importing file's directory, then the paths array passed to stylus.render(), then the resolve callback. When paths and a custom resolve callback are configured together, the intended precedence is not documented: it is unclear whether the first successful callback result short-circuits the remaining paths entries.
This matters for pnpm and yarn workspaces, where node_modules entries are symlinks and resolution reportedly follows the target's realpath — a behavior to confirm against the current release. If a shared .styl library is reachable both via paths and via a workspace link, precedence decides whether a package pulls in one copy of a partial or two, and produces duplicate CSS output.
A related gap: stylus.resolver() offers no option to change the extension search order (.styl, .css, index.styl, index.css) or suppress index lookup, so the callback cannot fully express desired import semantics.
- With
pathsandresolveboth set, what precedence is intended, and does a successful callback result stop thepathssearch? - Does realpath resolution apply to
pathsentries too, and is there a supported way to pin resolution to the symlink location? - Is any optional-import mechanism documented, or does failed resolution always throw for both
@importand@require?