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

Facing issue while exporting web-vitals/attribution using browserify #486

Closed
Archish27 opened this issue May 23, 2024 · 2 comments
Closed

Comments

@Archish27
Copy link

Unable to build using browserify when using

const {
  onCLS,
  onLCP,
  onFID,
  onINP,
  onFCP,
  onTTFB,
} = require("web-vitals/attribution");

Getting error while building browserify -

./node_modules/.bin/browserify -d  -t [ babelify --presets [ @babel/preset-env ] ] index.js > dist/bundle.js

/home/archish/code/agent-browser/node_modules/web-vitals/attribution.js:18
export * from './dist/web-vitals.attribution.js';
^
ParseError: 'import' and 'export' may appear only with 'sourceType: module'
@Archish27
Copy link
Author

Hey @tunetheweb,can you please help facing the above issue? Using Javascript with commonjs not using module.

@tunetheweb
Copy link
Member

There's some suggestions here which seem to work from a quick test: https://stackoverflow.com/questions/51023231/npm-browserify-import-and-export-may-appear-only-with-sourcetype-module.

Alternatively you can use } = require("web-vitals/dist/web-vitals.attribution.iife.js"); or } = require("web-vitals/dist/web-vitals.attribution.umd.cjs"); in your code.

But ultimately this is a browserify issue and not a web-vitals issue as far as I can tell so closing this.

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

No branches or pull requests

2 participants