Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require is not defined on vanilla js #1743

Closed
ing-fcastellanos opened this issue Sep 30, 2022 · 16 comments · May be fixed by hansogj/chrome-extension-discogs-tools#69
Closed

Require is not defined on vanilla js #1743

ing-fcastellanos opened this issue Sep 30, 2022 · 16 comments · May be fixed by hansogj/chrome-extension-discogs-tools#69

Comments

@ing-fcastellanos
Copy link

Hi!
I'm getting an error while loading the latest version from the vanilla js browser script (https://cdn.jsdelivr.net/npm/superagent):

version: 8.0.1
browser: Edge 105.0.1343.53, Chromium 105.0.5195.125
Console output:

Uncaught ReferenceError: require is not defined
    at superagent:1:14164
    at superagent:1:269
    at superagent:1:274
@lcoffin
Copy link

lcoffin commented Oct 1, 2022

Same here. Using either the jsdelivr.net or unpkg.com URLs. No code change on our end recently.

Browser: Firefox 105.0.1
Same error message as reported above.

@lcoffin
Copy link

lcoffin commented Oct 1, 2022

Note you can get around this by specifically requesting v8.0.0 using:

<script src="https://cdn.jsdelivr.net/npm/superagent@8.0.0"></script>

@titanism
Copy link
Collaborator

titanism commented Oct 3, 2022

Still determining the root cause of this

@titanism
Copy link
Collaborator

titanism commented Oct 3, 2022

v8.0.2 released - can you please test? @fcastellanosKreios @lcoffin

https://github.com/visionmedia/superagent/releases/tag/v8.0.2

@lcoffin
Copy link

lcoffin commented Oct 4, 2022

I'm still seeing the error with either of these URLs:

https://cdn.jsdelivr.net/npm/superagent
https://cdn.jsdelivr.net/npm/superagent@8.0.2

@8.0.0 works fine still.

@lcoffin
Copy link

lcoffin commented Oct 4, 2022

Note that I see this bit of code in 8.0.1 and 8.0.2 that I don't see in 8.0.0:

return"function"==typeof r&&W(t,".prototype.")>-1?_(r):r},V=require(12),Q=q("%TypeError%"),X=q("%WeakMap%",!0)

That's the only reference to require() anywhere in the code that I get.

@titanism
Copy link
Collaborator

titanism commented Oct 5, 2022

It must be something to do with babel or .dist.babelrc?

@titanism
Copy link
Collaborator

titanism commented Oct 5, 2022

tinyify v3.0.0 to v3.1.0 was changed here 1fc9682#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519L69-R68 which could be the culprit - the minor version change was common-shakeify bumping major versions here browserify/tinyify@1b0c002

Though this doesn't seem like it'd be the issue

@titanism titanism reopened this Oct 5, 2022
@titanism
Copy link
Collaborator

titanism commented Oct 5, 2022

Deprecated v8.0.1 and v8.0.2 in the interim - help would be appreciated in determining the underlying cause here. It has to do with creating the dist/superagent.min.js file.

@levino
Copy link

levino commented Oct 5, 2022

Please release v8.0.0 as v8.0.3. Less inconvenient for the users,

@lorand-horvath
Copy link

lorand-horvath commented Oct 21, 2022

@titanism Have you managed to find the underlying issue? Asking because npm install superagent still installs version 8.0.2 (even if it's deprecated) and not 8.0.0. Some kind of solution/fix would be very much appreciated until this problem is solved (perhaps releasing a temporary version 8.0.3).

@lorand-horvath
Copy link

lorand-horvath commented Oct 21, 2022

@titanism After some investigation regarding tinyify and common-shakeify (you mentioned them above), it seems that 5 days ago there were version bumps for both of them:
tinyify from 3.1.0 to 4.0.0 https://github.com/browserify/tinyify/releases/tag/v4.0.0
common-shakeify from 1.1.1 to 1.1.2 https://github.com/browserify/common-shakeify/releases/tag/v1.1.2

It looks like the latter has some related fixes to exports and invalid syntax, which might be the culprit and the fix:
Fix certain cases of exports in sequential expressions resulting in invalid syntax browserify/common-shakeify#43

Can you please check and see if updating to tinyify 4.0.0 and/or common-shakeify 1.1.2 would result in a correct build of superagent.min.js ?

lorand-horvath added a commit to lorand-horvath/superagent that referenced this issue Oct 22, 2022
@titanism
Copy link
Collaborator

v8.0.3 released to npm 🎉 !!

the issue was tinyify, which bumped common-shakeify, and has a few underlying issues that need resolved before we can upgrade it. apologies for the delay, this wasn't easy to track down.

https://github.com/visionmedia/superagent/releases/tag/v8.0.3

@patdahl
Copy link

patdahl commented Aug 15, 2024

This appears to be an issue again as of v10.

superagent@10.0.1:1

Uncaught ReferenceError: require is not defined
    at superagent@10.0.1:1:21563
    at superagent@10.0.1:1:269
    at superagent@10.0.1:1:274

@titanism
Copy link
Collaborator

v10.0.2 released with tinyify locked to 3.0.0 - can you try that @patdahl?

https://github.com/ladjs/superagent/releases/tag/v10.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants