Giter Club home page Giter Club logo

Comments (11)

lukastaegert avatar lukastaegert commented on July 28, 2024 3

You do not need a Babel plugin, you need an acorn plugin, namely 'acorn-jsx'. This will make Rollup's parser acorn handle JSX tokens.

See https://rollupjs.org/guide/en/#acorninjectplugins which exactly describes your use-case.

from plugins.

zanona avatar zanona commented on July 28, 2024 1

@shellscape

from plugins.

bhabgs avatar bhabgs commented on July 28, 2024 1

I've solved the problem。
And added some Babel components
源码地址
image

from plugins.

bhabgs avatar bhabgs commented on July 28, 2024

I had the same problem,for vue tsx!

let SiderBox = class SiderBox extends Vue {
    render() {
       return (<div>haha</div>);
    }
};

image

from plugins.

shellscape avatar shellscape commented on July 28, 2024

Hey folks (this is a canned reply, but we mean it!). Thanks to everyone who participated in this issue. We're getting ready to move this plugin to a new home at https://github.com/rollup/plugins, and we have to do some spring cleaning of the issues to make that happen. We're going to close this one, but it doesn't mean that it's not still valid. We've got some time yet before the move while we resolve pending Pull Requests, so if this issue is still relevant, please @ me and I'll make sure it gets transferred to the new repo. 🍺

from plugins.

shellscape avatar shellscape commented on July 28, 2024

@zanona pleas try the solution posted by @bhabgs. Happy to reopen if that doesn't fit the bill.

from plugins.

zanona avatar zanona commented on July 28, 2024

Hi, @shellscape. Unfortunately I am not using babel.

from plugins.

zanona avatar zanona commented on July 28, 2024

Thanks @lukastaegert.
I just tested and it worked pretty well. Thanks.
Considering this, would it be sensible to say that the preserve option on this plugin would only work when using it the way you suggested? It may be worth documenting it perhaps?

from plugins.

lukastaegert avatar lukastaegert commented on July 28, 2024

Definitely worth a docs update as it may help others with a similar use-case, PR welcome!

from plugins.

MartijnHols avatar MartijnHols commented on July 28, 2024

Is Acorn a last step of this plugin or a part of Rollup? I think it's the latter, so then shouldn't this only be necessary if you want to preserve JSX in the final output, but not if you want another plugin (e.g. babel) to compile it instead? The current text seems to suggest it's always required when jsx is set to preserve, while all I'm trying to achieve is have the raw JSX run through babel macros, then convert it to regular JS.

from plugins.

Greasen avatar Greasen commented on July 28, 2024

[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
packages/virtual-list/src/virtual-list.tsx

还是会有这样的情况发生,这是为什么?

from plugins.

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.