Giter Club home page Giter Club logo

Comments (13)

mathieudutour avatar mathieudutour commented on May 24, 2024 4

not part of skpm no, you need to install it separately: npm install @skpm/fs

from skpm.

mathieudutour avatar mathieudutour commented on May 24, 2024

you can't use fs directly because it's a node package and sketch plugins doesn't run on node. That being said, there is a way to access the file system using the NSFoundation APIs: NSFileManager, NSString.stringWithContentsOfFile_encoding_error, etc.

I started creating a package to polyfill the fs package on sketch: https://github.com/mathieudutour/sketch-module-fs but i was too lazy to do it entirely. If you want to contribute to it and if we manage to have a complete polyfill, we could include it automatically in skpm (like fetch and console here: #35)

from skpm.

mathieudutour avatar mathieudutour commented on May 24, 2024

Going to close this but feel free to ping me if you get the change to implement a polypill

from skpm.

abbrechen avatar abbrechen commented on May 24, 2024

Is it part of skpm now or how to use the sketch-module-fs?

from skpm.

abbrechen avatar abbrechen commented on May 24, 2024

Thanks a lot.

from skpm.

narendrasinghrathore avatar narendrasinghrathore commented on May 24, 2024

Module not found: Error: Can't resolve 'fs'

from skpm.

mathieudutour avatar mathieudutour commented on May 24, 2024

Have you read the previous comments?

from skpm.

narendrasinghrathore avatar narendrasinghrathore commented on May 24, 2024

Yes, @mathieudutour I did.
But the issue is, I am using a node module which eventually depends on multiple node modules.
So I think It's not a feasible solution to manually update all imports

   const fs  = require('fs')

   to

   import * as fs from '@skpm/fs'

Can you please share something more generic, because there can be the case where the one dependent node module in our app internally depends on multiple node modules which depends on 'fs'?

 inception 🤯

Please let me know if I missed something.

Thanks

from skpm.

mathieudutour avatar mathieudutour commented on May 24, 2024

Please write a comment like that the first time next time 🙂

You don't have to manually update all imports, you can tell webpack to do it for you https://webpack.js.org/configuration/resolve/

That being said, @skpm/fs only implements the synchronous API so depending on thee modules you are using, it might still not work.

from skpm.

narendrasinghrathore avatar narendrasinghrathore commented on May 24, 2024

@mathieudutour thanks for quick response, can you suggest some alternative to this.

from skpm.

mathieudutour avatar mathieudutour commented on May 24, 2024

Use another module?

from skpm.

narendrasinghrathore avatar narendrasinghrathore commented on May 24, 2024

giphy
@mathieudutour

from skpm.

mathieudutour avatar mathieudutour commented on May 24, 2024

That's not a joke. There isn't any other fs polyfill for Sketch as far as I know. So if you can't use this one, you will need to find a workaround which might be to use a module that doesn't need fs

from skpm.

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.