Comments (10)
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.
@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.
This also break my import './some-my-style.css';
.
from plugins.
@Rich-Harris is this one still relevant?
from plugins.
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.
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.
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.
@lukastaegert could you give a small example of using this.resolve
?
Cheers.
from plugins.
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.
#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)
- [@rollup/plugin-esm-shim] Shim inserted incorrectly if source file has `import` in comment HOT 1
- [@rollup/plugin-node-resolve] confusion about what this plugin does HOT 2
- How to tell `--configPlugin` to use specific `tsconfig`? HOT 5
- [@rollup/plugin-node-resolve] resolving package.json exports/imports arrays HOT 1
- Source URLs in generated source map are wrong when `composite` is enabled in tsconfig.json
- requireReturnsDefault: "auto" results in an incorrect bundle for some libraries
- [@rollup/plugin-alias] Allow to configure alias based on entry point
- 在SCSS中如何替换Var变量
- Allow @rollup/plugin-virtual to be a function that takes a module ID
- [@rollup/plugin-tpescript] Rollup does not use `paths` in `rollup.config.ts`
- [@rollup/plugin-typescript] allowImportingTsExtensions warning
- [@rollup/plugin-tpescript] Rollup does not get `module` and `moduleResolution` settings from extended `tsconfig.json`
- [@rollup/plugin-json] won't process files without json suffix HOT 4
- CommonJS plugin version bump to 26.0.0 causes build issue HOT 4
- Confusing explanation in @rollup/plugin-typescript's README
- [@rollup/plugin-swc] leads to unusable bundle in combination with [@rollup/plugin-commonjs] and [@rollup/plugin-node-resolve]
- I don't know if this is a mistake
- Wasm plugin to support latest ESM Integration & Source Phase Imports
- [@rollup/plugin-json] inclusion/exclusion filter fails HOT 2
- Error message when node module doesn't exist doesn't... exist
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plugins.