Skip to content
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

feat: inject compilerOptions into customRenderer #80

Merged
merged 4 commits into from Apr 27, 2020

Conversation

dancon
Copy link
Contributor

@dancon dancon commented Mar 15, 2020

I fix the issue#77,

I write a new npm package less-plugin-aliases and inject compilerOptions into the customRenderer that I can resolve the @import ~path manually.

The general use case is as below:

{
  "compilerOptions": {
    "plugins": [
      {
        "name": "typescript-plugin-css-modules",
        "options": {
          "classnameTransform": "camelCase",
          "customMatcher": "\\.less$",
          "customRenderer": "node_modules/less-plugin-aliases/lib/customRender.js"
        }
      }
    ],

    // ...
  }
}

ps: My english is poor, maybe there are some mistakes in README.md, pls fix it if you find ~

@dancon
Copy link
Contributor Author

dancon commented Mar 15, 2020

@mrmckeb pls take a time to review.

Copy link
Owner

@mrmckeb mrmckeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, thanks @dancon - only one small suggestion, and I'll also add a little more to the docs before release.

I also wonder if you could use the customRenderer like the below? It should work.

        "options": {
          "classnameTransform": "camelCase",
          "customMatcher": "\\.less$",
          "customRenderer": "less-plugin-aliases"
        }

src/helpers/getDtsSnapshot.ts Outdated Show resolved Hide resolved
@dancon
Copy link
Contributor Author

dancon commented Mar 16, 2020

This looks good, thanks @dancon - only one small suggestion, and I'll also add a little more to the docs before release.

I also wonder if you could use the customRenderer like the below? It should work.

        "options": {
          "classnameTransform": "camelCase",
          "customMatcher": "\\.less$",
          "customRenderer": "less-plugin-aliases"
        }

It depends on the way the plugin load customRenderer, and it seems not working for now, becasuse you resolve the options.customRenderer base current directory here

I notice that when I write the less plugin, and decided finally not to touch it , becasuse the usage like node_module/less-plugin-aliases/lib/customRender.js is not a big deal, and if want to load npm package directly need more code for compatibility. I can do that, but maybe next version, is that ok?

I make a commit to support loading npm package as customRenderer.

And less-plugin-aliases default export a plugin for less, not a customRender for this ts plugin, so, after support load package from node_modules, the usage like below is acceptable?

"options": {
         "classnameTransform": "camelCase",
         "customMatcher": "\\.less$",
         "customRenderer": "less-plugin-aliases/lib/customRender.js"
 }

@dancon dancon requested a review from mrmckeb March 16, 2020 14:19
@dancon
Copy link
Contributor Author

dancon commented Mar 17, 2020

@mrmckeb
Copy link
Owner

mrmckeb commented Mar 31, 2020

Hi @dancon, very sorry about the slow reply.

This looks great. I'll merge today/tomorrow and add some tests for this too. I'll release by the end of the week :)

@mrmckeb mrmckeb merged commit 76d75d6 into mrmckeb:develop Apr 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants