Comments (7)
I was confused as well at first, then I read a little bit the internals of rollup. The resolution order may be important, depending on how a given plugin works. For example, if you have a chain and you import path
in your project, a plugin could either ignore the import because is a builtin, passing the responsibility to the next one in the chain, or "swallow" the import, breaking the expected result.
Rollup applies a resolution algorithm using chain of responsibility pattern, I think. But usually you should not have issues with the ordering.
from rollup-plugin-includepaths.
Hello!
I can't reproduce your problem using only the includepaths plugin and the builtins plugin together. The issue seems to be somewhere else.
This is the config I used to run a test:
https://gist.github.com/darlanalves/8bce333fdec2891991af2ecf3b1790e1
Running rollup with these files and then running the final app.js
with node will show a list of methods on path module.
from rollup-plugin-includepaths.
@darlanalves, hello and thanks for response.
I've prepared a simple configuration which mimics my problem one.
At this revision everything is ok. I can resolve path
builtin (however not using it, so Rollup effectively reduces it to single function expression). Then I uncomment include
(3) and get warning about path
, and it stops resolving. Then I can uncomment (1) or (2) to show that include
not working as well.
from rollup-plugin-includepaths.
Hello!
I've ran your setup. Indeed there are some issues there but they're due to config only.
Changing the builtins and includepath configs to this will build sucessfully:
plugins: [
include({ external: [], paths: [ 'buns' ] }),
builtins(),
// ...
]
Some notes about it:
- includePaths plugin, by default, marks all the node builtins as external modules. This is not in the docs, my fault. I'm adding there to clarify. Due to this, since you did not mention the
external
config, it was leaving thepath
module outside the bundle. - You don't need to add
__dirname
in the source paths. All the paths are resolved to current folder. - A good practice, and a thing that will break rollup: Avoid running any module code before finishing all the imports. In your example, the
foo()
call before other imports.
And a side note about path: the builtins plugin had an issue, so you'll need to check for a new release that includes this PR.
Here's an updated setup working. Running the bundled file will present the list of available methods on path
module.
Let me know if you're still facing issues :)
from rollup-plugin-includepaths.
@darlanalves, well I'm glad that issue is commonly on side of my config and not Rollup ecosystem.
Before this issue I was experimenting with external
option both of Rollup and includepaths
, but I exclude path
by myself. Semees that I should exclude path
, not include it in this option. Thanks for clarification here π
Passing empty array to includepaths
external seemes working on my current workflow. π
- I've included dirname because I use not simple paths, but paths provided by rootpath β a tool which I use to expressively work with path hierarchies. So I have
__dirname
under hood and I wanted to be sure that my test configuration copies my battle one.
Avoid running any module code before finishing all the imports.
- I totally agree with you, I just wanted to have ref to
foo
, so Rollup didn't shake it away.
What do you think about order of plugins? Does they order matter? Should includepaths
go first? I'm not familiar with Plugins API well.
from rollup-plugin-includepaths.
attached repo with your solution included, for history.
from rollup-plugin-includepaths.
@darlanalves Thanks for help again.
from rollup-plugin-includepaths.
Related Issues (18)
- Resolve `<module-name>/index.js` HOT 4
- Doesn't seem to work with module marked as external HOT 4
- Usage with `commonjs` & `node-resolve`? HOT 2
- Add a `strict` option for path resolution HOT 2
- does not load module index with other extensions HOT 2
- question: How to make it work with eslint? HOT 1
- "external" option doesnβt accept function as value HOT 1
- Breaking changes in updates 0.1.x HOT 1
- Resolve against package.json main field
- Unable to resolve file path? HOT 1
- External option is overrided by the plugin if it is a function HOT 2
- Any interest in supporting TypeScript at some point? HOT 1
- Smart resolve or wildcards HOT 1
- `resolveCachedPath` ignores `origin` HOT 5
- 0.1.4 caused `TypeError: rollupIncludePaths is not a function` on Ubuntu 16.04 HOT 2
- diamond import/export structure fails
- "filepath" does not exist in the hypothetical file system! #772 HOT 1
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 rollup-plugin-includepaths.