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

ESM build contains keyword require crash web app #1073

Closed
joshuajiangdev opened this issue Jan 22, 2022 · 4 comments
Closed

ESM build contains keyword require crash web app #1073

joshuajiangdev opened this issue Jan 22, 2022 · 4 comments

Comments

@joshuajiangdev
Copy link

joshuajiangdev commented Jan 22, 2022

Hi, I'm getting ReferenceError: require is not defined from my web at the line ul=require("js-cookie"). My vite build is using build targets modules, which according to this libs' package.json:

  "main": "cjs/index.js",
  "module": "esm/index.js",
  "browser": "dist/okta-auth-js.umd.js",

is going to load package from "esm/index.js", so I checked that file and could find the code var Cookies = require('js-cookie'); there. Curious if this is intended or a mistake to include keyword require keyword in an esm build.

@oleksandrpravosudko-okta
Copy link
Contributor

Thanks for report @joshuajiangdev.

This issue is likely to be addressed in the the next major releases. Until then, you could either resolve umd bundle or use helper plugin.

@tejasdharamshi
Copy link

tejasdharamshi commented Jan 24, 2022

Do you have timelines for the next release?

@shuowu
Copy link
Contributor

shuowu commented Feb 10, 2022

Another options is to let babel loader to transpile the ESM bundle, here is an example to follow.

@shuowu
Copy link
Contributor

shuowu commented Mar 4, 2022

Fixed in v6.2.

@shuowu shuowu closed this as completed Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants