fitty icon indicating copy to clipboard operation
fitty copied to clipboard

SyntaxError: Unexpected token export

Open 7zf001 opened this issue 4 years ago • 7 comments

Hi

Why can't I import directly in Jest?

code:

import fitty from 'fitty';

Throw error: image

7zf001 avatar Oct 01 '21 03:10 7zf001

I found a solution: u must change your import to import fitty from 'fitty/dist/fitty.min.js' it works perfectly for me

vlad909 avatar Dec 15 '21 17:12 vlad909

@vlad909 yup, thanks, that’s what I did.

7zf001 avatar Dec 16 '21 08:12 7zf001

@vlad909's solution did not work for me since typescript would complain about missing types.

Ugly workaround for me:

// eslint-disable-next-line @typescript-eslint/no-var-requires
const fitty = require("fitty/dist/fitty.min.js");

maxfriedmann avatar Jan 10 '22 10:01 maxfriedmann

Such a non-elegant solution. Someone who works on the library may consider submitting a PR to fix this.

varunarora avatar Aug 03 '22 19:08 varunarora

Such a non-elegant solution. Someone who works on the library may consider submitting a PR to fix this.

@varunarora feel free to do it 😉

flexbox avatar Jan 24 '23 14:01 flexbox

Actually just change the primary entry point in package.json from dist/fitty.module.js to dist/fitty.min.js is okay

chou0728 avatar Sep 22 '23 03:09 chou0728

Updated

main now points to fity.min.js

module now points to fitty.module.js

rikschennink avatar Nov 17 '23 12:11 rikschennink