GithubHelp home page GithubHelp logo

Comments (7)

darlanalves avatar darlanalves commented on July 19, 2024 1

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.

darlanalves avatar darlanalves commented on July 19, 2024

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.

StreetStrider avatar StreetStrider commented on July 19, 2024

@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.

darlanalves avatar darlanalves commented on July 19, 2024

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 the path 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.

StreetStrider avatar StreetStrider commented on July 19, 2024

@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.

StreetStrider avatar StreetStrider commented on July 19, 2024

attached repo with your solution included, for history.

from rollup-plugin-includepaths.

StreetStrider avatar StreetStrider commented on July 19, 2024

@darlanalves Thanks for help again.

from rollup-plugin-includepaths.

Related Issues (18)

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.