Coder Social home page Coder Social logo

Comments (11)

gmaclennan avatar gmaclennan commented on June 20, 2024 1

Ok I see the problem. The files field in the current package.json means that the lib folder is not being included in the tarball when published to npm, so everything will fail when installing from npm. Probably best just to remove that field, and use .npmignore to blacklist rather than whitelist files. I'm just heading out for the weekend now, so probably won't get round to doing this until next week.

FYI I tested the bundle without publish with npm pack then from a tmp local folder npm i ../cuid/cuid-2.0.0.tgz

from cuid.

MarkHerhold avatar MarkHerhold commented on June 20, 2024

Just to clarify the point on node_modules, we currently don't have any node_modules to bundle as this library only has dev dependencies in package.json.

@ericelliott, could you give a specific use case of someone running into an issue using cuid? I'm guessing this case wouldn't involve a build tool like webpack or browserify since these tools already bundle everything that is needed.

from cuid.

gmaclennan avatar gmaclennan commented on June 20, 2024

I'm unclear about the exact nature of the bug? Both webpack and browserify should be fine with bundling with the main field pointing to index.js, although I have not tested webpack with the latest version. I am unclear about how Webpack respects the browser field in package.json - the docs state that it is supported but perhaps only as string values?

We could include the build files in the npm bundle by adding an empty .npmignore file (which would stop npm from ignoring the dist in the .gitignore - https://docs.npmjs.com/misc/developers#keeping-files-out-of-your-package) then users could require('cuid/dist/cuid'), however, I notice that we only build a node version, not a browser or react-native version. We should probably fix that.

Any feedback from users about what warnings or errors they are getting from Webpack would help resolve things.

from cuid.

ericelliott avatar ericelliott commented on June 20, 2024

FYI I tested the bundle without publish with npm pack then from a tmp local folder npm i ../cuid/cuid-2.0.0.tgz

I hadn't thought of that. Thanks for the tip!

from cuid.

ericelliott avatar ericelliott commented on June 20, 2024

Any progress?

from cuid.

pyrossh avatar pyrossh commented on June 20, 2024

We need to add fuse-box also as a bundler. Its not working since its trying to load the os package. Wouldn't it better if we have 2 packages.
Anyways fusebox provides a global process env variable with these fields
{title: "browser", browser: true, env: {…}}. Maybe we could use this to switch which packages are loaded.
And also what about react-native, how would it run in that environment?

from cuid.

ericelliott avatar ericelliott commented on June 20, 2024

Good questions. Please explore and let me know what you figure out. =)

from cuid.

notrab avatar notrab commented on June 20, 2024

I'm having issues with using rollup and I was wondering if anyone here has had a similar issue?

The error I get back is Uncaught TypeError: n is not a function and the sourcemap reveals this to be a function that returns cuid().

If I replace cuid() with something else, it works.

Love to hear any suggestions @ericelliott 😄

from cuid.

ericelliott avatar ericelliott commented on June 20, 2024

@notrab

If the function returns the result of calling cuid(), that would be a string, not a function. We'd need more context to say much more. What does the function look like, and what is its intended purpose?

from cuid.

nevf avatar nevf commented on June 20, 2024

@ericelliott Same problem using parcel.js - "Its not working since its trying to load the os package."

from cuid.

ericelliott avatar ericelliott commented on June 20, 2024

I think our new browser tests have this covered?

from cuid.

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.