Giter Club home page Giter Club logo

browser-injection's Introduction

I've created the following minimal example which you can refer to to understand what my issue is: https://github.com/marijanp/browser-injection

In my project I'm using a transitive dependency which requires path equivalent to this projects main.js, this means that I don't have access to this package and I can't refactor it. And there is not just one of those dependencies rather many, so refactoring is also not feasible.

The build phase in my project looks similar to what happens in packages.x86_64-linux.inject-browser in the flake.nix. I export the node_modules which I get using npmlock2nix and I call esbuild.

You can run nix build .#inject-browser to see the error message that is thrown, that it doesn't know about the dependency and whether I want to use node.

And obviously if I add --platform=node the esbuild call in the flake.nix the build succeeds. But I actually want to build for the browser, not for node. How do I achieve this?

Solution:

Together with @toastal I wrote the esbuild builder (see flake.nix) which calls the esbuild javascript API with a plugin from node-stdlib-browser, which in turn takes care of replacing node dependencies with the respective browser implementation.

browser-injection's People

Contributors

marijanp avatar

Stargazers

Andrejs Agejevs avatar

Watchers

Sridhar Ratnakumar avatar  avatar  avatar

Forkers

srid

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.