Coder Social home page Coder Social logo

Comments (8)

FredKSchott avatar FredKSchott commented on July 20, 2024 2

Actually, it looks like this could work: https://www.npmjs.com/package/babel-plugin-bare-import-rewrite

{
    "plugins": [
        ["bare-import-rewrite", {
            "modulesDir": "/web_modules",
            "alwaysRootImport": ["**"]
        }]
    ]
}

Trying it out in a project now

from snowpack.

FredKSchott avatar FredKSchott commented on July 20, 2024 2

Done! If you install @pika/web v0.2.0 (latest) you can load it into your babelrc like so:

 {
  "plugins": [
    ["@pika/web/assets/babel-plugin.js"]
  ]
}

Still experimental, and might split it out into it's own package before v1, but that gets you want you need!

from snowpack.

FredKSchott avatar FredKSchott commented on July 20, 2024

Sure! We'd need to decide what's automatically doing the prepending, Babel?

from snowpack.

stramel avatar stramel commented on July 20, 2024

How would that work when using both node_moduoes and web_modules?

from snowpack.

FredKSchott avatar FredKSchott commented on July 20, 2024

Okay I tried out every babel plugin I could and no luck. I think we may just want to write one ourselves.

from snowpack.

FredKSchott avatar FredKSchott commented on July 20, 2024

README updated as well

from snowpack.

cktang88 avatar cktang88 commented on July 20, 2024

Awesome! What's the behavior if there's a conflict between node_modules and web_modules?

from snowpack.

FredKSchott avatar FredKSchott commented on July 20, 2024

The plugin is super dumb for now, it just rewrites every "bare name" package import to it's web_modules/ file equivalent Β―\(ツ)/Β―

from snowpack.

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.