Giter VIP home page Giter VIP logo

Comments (6)

LukasMachetanz avatar LukasMachetanz commented on May 23, 2024 1

Ah; I see. ;)

I will try it. Hopefully I get it to work without the need to consult you again. :)
If I am successful I would be glad contributing back. As I said, I really appreciate the handbook. Therefore I imagine that it could help others as well.

from typescript-transformer-handbook.

itsdouges avatar itsdouges commented on May 23, 2024

heya! currently there are issues (either a bug, oversight, or deliberate thing by the TypeScript team) when compiling down to common js and applying custom transformers - basically the imports don't get "bound" in the binding step and thus their usage areas don't get renamed...

i got around this in Compiled by... hacks... I'm not sure if this is in the handbook TBH https://github.com/atlassian-labs/compiled-css-in-js/blob/master/packages/ts-transform/src/constants.tsx#L48

from typescript-transformer-handbook.

LukasMachetanz avatar LukasMachetanz commented on May 23, 2024

Hey. Thank you for the immediate answer. Do I understand it correctly that the provided link is already the solution to the described problem? If this is the case I definitely have to try it. I am curious if it will work.

And btw why do you know such stuff? Unbelievable. :)
Am I wrong or is there really not much documentation out there? Anyhow; great work. I really appreciate the support.

from typescript-transformer-handbook.

itsdouges avatar itsdouges commented on May 23, 2024

It's a work around not really a solution 😅 - I found this by trial and error. There really isn't much information about this which is why I made the handbook in the first place.

If you get this working want to contribute back and mention this workaround in the handbook?

from typescript-transformer-handbook.

LukasMachetanz avatar LukasMachetanz commented on May 23, 2024

Sorry but I have to clarify the solution again. I think I understand the code snippet. But I do not understand in which "context" they are applying it.

  • The whole "mechanism" starts when the target is CommonJS
  • If this is the case they just add the "binding"
  • If not ... the "binding" does not have to be added

Is this right? So in short: They are doing what I had in mind: it is necessary to add the "binding" manually, right?

Just some questions if I got it correctly:

  • So for my example ttransformer_1 would have to be added manually, right?
  • The added import declaration is correct, right? It does not have to be touched?
  • In my case just the line if (!Ttransformer.isInTransformContext()) { would have to be updated, right?

This is the part from the transformer:

ts.createPropertyAccess(ts.createIdentifier("Ttransformer"), ts.createIdentifier("isInTransformContext")),

Here I would have to add the ttransformer_1 additionally, right?

So I would guess something like this:

  ts.createPropertyAccess(
    ts.createPropertyAccess(
      ts.createIdentifier("ttransformer_1"),
      ts.createIdentifier("Ttransformer")
    ),
    ts.createIdentifier("isInTransformContext")
  ),

I just wanted to clarify and check if I understood it correctly. In the best case you just have to give me a thumb up. Thanks. ;)

from typescript-transformer-handbook.

itsdouges avatar itsdouges commented on May 23, 2024

I've gotten this reply from the TS team as to how we could work around the problem microsoft/TypeScript#38077

from typescript-transformer-handbook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.