GithubHelp home page GithubHelp logo

Comments (4)

theKashey avatar theKashey commented on August 23, 2024 1

Frankly speaking - have no idea how to conditionally target package for a 'worker'. Probably it will be node + browser + default (not node and not browser).
But you know - if something is not clear, and ESM/node exports are 'not clear' - let's not use it. And this is why I am not using them.

You might look into two solutions:

  • (isolate, preferred) a separate named entrypoint for a worker. Just put a package.json into a named directory.
  • (hide, popular) remove import from 'fs' and do eval("require('fs')") where needed.

from used-styles.

theKashey avatar theKashey commented on August 23, 2024 1

That is actually a really good solution to unblock yourself as well as being able to verify assumption and provide a way forward for the 'mainstream'

from used-styles.

wellyshen avatar wellyshen commented on August 23, 2024

Hey @theKashey, I have tested this library with Clouldflare worker, and it works great. All we need is to use loadStyleDefinitions and pass the client assets through Couldfare KV for dev/prod. So I'm trying to split the loadStyleDefinitions from discoverProjectStyles (which relies on fs that doesn't run on worker). And plan to use conditional exports for the worker users. But I'm wondering how to export different build files by lib-builder? Can't find related documents for that 🤔

from used-styles.

wellyshen avatar wellyshen commented on August 23, 2024

Hmm... the wired thing is even though we did isolate, once a module containing fs related things is exported that isn't used in the project, the worker still initializes it and fails to run.

For now, I will fork this library and modify it for running on the worker.

from used-styles.

Related Issues (20)

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.