Giter Club home page Giter Club logo

rollup-plugin-import-alias's People

Contributors

danielkalen avatar hedzer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rollup-plugin-import-alias's Issues

Doesnt work with non-javascript files

Hi! Thanks for the great plugin. Unfortunately, it seems that it does not work with any file type besides javascript. Whenever I want to resolve .ts files, rollup complains:

[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)

I have tried to change the plugin order and added this plugin AFTER babel has transpiled the Typescript to Javascript, but the Error is the same.

The generated resolveIds are not absolute paths, and thus do not match relative imports.

Hello,

I found a bug where an aliased import and a relative import ostensibly to the same file actually appeared to point at different files.

Say I have a project structure:

my_modules/
  bar.js
src/
  test.js

bar.js:

class Bar {
}
export default Bar

And I have an alias set up like this:

alias({
  Paths: {
    'bar': './my_modules/bar'
  }
})

Then the following will occur in test.js:

import bar from 'bar'
import bar2 from '../my_modules/bar'

console.log(bar === bar2) // prints "false"

This is because rollup by default resolves ids to absolute file paths with path.resolve(). With different resolveIds, the two imports resolve as completely different modules, with different side effects and class definitions. In my limited testing, I was able to fix this by wrapping line #28 in import-alias' index.js:

// from
var directory = importee.replace(entry.key, entry.path);
// to
var directory = path.resolve(importee.replace(entry.key, entry.path));

This means that the aliased import and the relative import will point to the same files, and rollup will resolve both imports as the same module.

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.