Parse-SDK-JS icon indicating copy to clipboard operation
Parse-SDK-JS copied to clipboard

UUID/v4 require() uses a deprecated approach, can cause issues with other packages

Open jpgupta opened this issue 3 years ago • 1 comments

New Issue Checklist

Issue Description

I've been trying to set up a Serverless environment, using Node, AWS Lambda and Parse. In development everything is working fine but when I try to deploy it, I run into the following error:

unable to resolve path to module 'uuid/v4' Screenshot 2022-06-06 at 23 03 26

The problem seems to be that the version of UUID Parse is using, 3.x, is outdated - but further than that, the way that it is being imported ('deep require'), is also discouraged. See https://github.com/uuidjs/uuid#deep-requires-now-deprecated Screenshot 2022-06-06 at 23 10 47

For reference, the other package I am using that also depends on UUID is AWS's V3 Lambda SDK (@aws-sdk/client-lambda)

In my case, I think this is conflicting with the version of UUID used by other packages, and Yarn warns me tht the uuid package is 'being externalised in two different places', and that it will pick the latest version to use.

This means that in my repo, the latest (8.x) version of UUID is being used instead of Parse's (3.x). This causes a problem because whilst the UUID RFC v4 standard is still available with UUID 8.x, it can no longer be imported/required with require('uuid/4') and instead the maintainers want you to use a named import.

I know that package managers should usually handle this scenario (e.g. two dependenceis each relying on different versionf of a pacakge)... however I think the specific way the package is being required() here and then exported... when combined with other packages.. is causing a problem (I only have a working knowledge of how this works under the hood).

I'm opening this issue, and an associated PR to update the Parse's UUID dependency to the latest version, and to use the required commonjs appraoch for importing v4.

This fixes the problem with my repo - I appreciate that... whatever the underlying problem is with these two pacakges, it may not be the Parse SDK's 'fault'... however I thought it would be worth opening this PR anyway as it updates a fairly outdated dependency, and brings the way it is used/imported more in line with modern practice. (see https://github.com/uuidjs/uuid#deep-requires-now-deprecated for more info)

Steps to reproduce

I won't produce detailed STR for now just because it would require a fairly large 'minimal reproduction' involving AWS SDKs, Serverless framework and Parse and, I'm going to open a PR directly after this issue which is only a few LOC change and should be fairly self explanatory when viewed alongside this issue.

As a rough narrative STR - I am trying to build and deploy a Serverless Framework project that uses a Nuxt (Vue) server side environment, with Node, AWS Lambda SDK and Parse.

Actual Outcome

Project builds in development mode, but fails to deploy to Serverless. When Serverless tries to build it, it produces the error described above (unable to resolve uuid/v4).

Expected Outcome

I expect that the project will run in development mode, build for production, and can be packaged using the Serverles framework

Environment

Parse JS SDK 3.4.2 Yarn 3.2.1

Serverless Framework, AWS Lambda (version numbers not provided as it is not relevant to the scope of this issue and the proposed PR)

Logs

Error: Error: Build failed with 1 error: .output/server/node_modules/parse/lib/node/uuid.js:4:15: ERROR: Could not resolve "uuid/v4" at failureErrorWithLog (/Users/jamesgupta/Documents/GitHub/synap-labs/packages/nuxt3/node_modules/esbuild/lib/main.js:1611:15) at /Users/jamesgupta/Documents/GitHub/synap-labs/packages/nuxt3/node_modules/esbuild/lib/main.js:1257:28 at runOnEndCallbacks (/Users/jamesgupta/Documents/GitHub/synap-labs/packages/nuxt3/node_modules/esbuild/lib/main.js:1170:65) at buildResponseToResult (/Users/jamesgupta/Documents/GitHub/synap-labs/packages/nuxt3/node_modules/esbuild/lib/main.js:1255:7) at /Users/jamesgupta/Documents/GitHub/synap-labs/packages/nuxt3/node_modules/esbuild/lib/main.js:1364:14 at /Users/jamesgupta/Documents/GitHub/synap-labs/packages/nuxt3/node_modules/esbuild/lib/main.js:674:9 at handleIncomingPacket (/Users/jamesgupta/Documents/GitHub/synap-labs/packages/nuxt3/node_modules/esbuild/lib/main.js:771:9) at Socket.readFromStdout (/Users/jamesgupta/Documents/GitHub/synap-labs/packages/nuxt3/node_modules/esbuild/lib/main.js:640:7) at Socket.emit (events.js:375:28) at Socket.emit (domain.js:470:12) at addChunk (internal/streams/readable.js:290:12) at readableAddChunk (internal/streams/readable.js:265:9) at Socket.Readable.push (internal/streams/readable.js:204:10) at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)

jpgupta avatar Jun 06 '22 22:06 jpgupta

Thanks for opening this issue!

  • 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

Closing via https://github.com/parse-community/Parse-SDK-JS/pull/1718

dplewis avatar Feb 04 '23 00:02 dplewis