Add support for package subpaths for plugins
See original GitHub issueWhat is the problem you’re trying to solve?
Hello!
So I have a package called @rhds/tokens
, which has a bunch of stuff in it, including:
- a
main
module that exports some js unrelated to stylelint at./js/tokens.cjs
- a stylelint plugin module at
./plugins/stylelint.cjs
I don’t want to mark the stylelint plugin as the main
module, because its not, but I’d like users to be able to load up the plugin in their config, which is possible by referencing the file in node_modules, but a little less aesthetic.
What solution would you like to see?
plugins:
- - ./node_modules/@rhds/tokens/plugins/stylelint.cjs
+ - '@rhds/tokens'
This could be accomplished nicely with a node module export conditions:
"exports": {
"stylelint": {
"require": "./plugins/stylelint.cjs",
"import": "plugins/stylelint.js"
}
}
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
How to support subpath imports using React+Rollup+Typescript
This post documents the steps taken to build a hybrid NPM package (supports ESM + CJS) from React component library that supports subpath...
Read more >supporting subpath imports in rollup - Stack Overflow
supporting subpath imports in rollup ... dist/esm/Button: Button CustomButton.d.ts index.js package.json Button.d.ts index.d.ts index.js.map.
Read more >Modules: Packages | Node.js v19.3.0 Documentation
Exports sugar; Subpath imports; Subpath patterns; Conditional exports ... For packages supporting Node.js 10 and below, the "main" field is required.
Read more >rollup-plugin-subpath-externals - npm
Externalize all dependencies, even subpath imports. Latest version: 3.4.0, last published: 3 years ago.
Read more >Gatsby sanity deploy issue - Netlify Support Forums
Error: [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath '. ... 9:17:40 PM: npm WARN gatsby-plugin-image@1.14.2 requires a peer of ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
i’ve used my own custom conditions in the past, and some tools like esbuild support them
Currently, Stylelint imports a plugin module here:
https://github.com/stylelint/stylelint/blob/0967b9c3650812be83ae4c4dddb00e3958e4826d/lib/augmentConfig.js#L325
If we implement the feature, is it necessary to change the code above?
Also, do we need to add a CLI flag like
--conditions=stylelint
to the following shebang? (--conditions
seems experimental, though)https://github.com/stylelint/stylelint/blob/0967b9c3650812be83ae4c4dddb00e3958e4826d/bin/stylelint.js#L1
We would appreciate it if you have any code examples that would be helpful.