hedzer / rollup-plugin-import-alias Goto Github PK
View Code? Open in Web Editor NEWProvides directory aliases for es2015 import statements.
Provides directory aliases for es2015 import statements.
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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.