Giter Club home page Giter Club logo

Comments (10)

andrezsanchez avatar andrezsanchez commented on July 28, 2024 7

This is preventing me from using this in a TypeScript build setup because it is automatically adding .js when I just want to put .ts

from plugins.

hansemannn avatar hansemannn commented on July 28, 2024

@Rich-Harris I'd love to see this integrated, even if it requires a major bump. Otherwise, an alternative or workaround would be appreciated!

from plugins.

gluons avatar gluons commented on July 28, 2024

This also break my import './some-my-style.css';.

from plugins.

shellscape avatar shellscape commented on July 28, 2024

@Rich-Harris is this one still relevant?

from plugins.

dumbmatter avatar dumbmatter commented on July 28, 2024

I just ran into this problem too, when I want to alias a JSON file and then load it with rollup-plugin-json, it fails because this configuration:

{find: 'aliased-json', replacement: './test.json'},

makes it look for test.json.js.

So I have to create a dummy JS test.js next to test.json that just imports and exports test.json, and then alias to that rather than my JSON file.

If a non-breaking change was desired, an option could be added to disable the automatic file extension.

EDIT: Sorry, I just realized what the resolve option does. Still seems like it'd be better to change the default behavior :)

from plugins.

northkode avatar northkode commented on July 28, 2024

webpack has a similar thing that allows us to alias directories so we can even alias to asset files that might be images.

Currently my config is

alias({
            '@assets': __dirname + '/src/assets'
        }),

And i'm doing
import png from "@assets/icon.png";

but this adds .js to the end of the file.. which is not ideal. it seems alias shouldnt be bound to a file type assumption.

from plugins.

lukastaegert avatar lukastaegert commented on July 28, 2024

Another approach could be to use the this.resolve context function to resolve this. If someone were to use rollup-plugin-node-resolve, they get the resolution algorithm they know and love, otherwise just what is built-in. @Acionyx has been contacting me because he is working on a fork to do just that but I did not yet find time to have a look.

from plugins.

chopfitzroy avatar chopfitzroy commented on July 28, 2024

@lukastaegert could you give a small example of using this.resolve?

Cheers.

from plugins.

lukastaegert avatar lukastaegert commented on July 28, 2024

Here is a real-world example, though it is probably not a simple one: https://github.com/rollup/rollup-plugin-commonjs/blob/535e8117607731e1e8688be84c3aeb6e5c3b6fa5/src/resolve-id.js#L54

Here it is taking an import of the form commonjs-proxy:./some-imports.js, removes the prefix and uses this.resolve to find out what path the import of ./some-import.js resolves to.

from plugins.

shellscape avatar shellscape commented on July 28, 2024

#34 was merged and published a little while back. It now uses this.resolve() and should alleviate this issue. If it still pops up with the new version, please respond and we'll reopen.

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.