question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for package subpaths for plugins

See original GitHub issue

What 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:open
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bennypowerscommented, Aug 26, 2022

i’ve used my own custom conditions in the past, and some tools like esbuild support them

0reactions
ybiquitouscommented, Aug 30, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found