janne / pluscodes

Javascript library to encode and decode plus codes
20 stars 2 forks source link

Error: require function is used in a way in which dependencies cannot be statically extracted #12

Open dawnerd opened 2 years ago

dawnerd commented 2 years ago

Trying to use this but looks like there might be an issue with exports:

import { decode } from "pluscodes";

same issue if I do this too:

const { decode } = require('pluscodes')
warn  - ./node_modules/pluscodes/dist/decode.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

./node_modules/pluscodes/dist/encode.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

./node_modules/pluscodes/dist/expand.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

./node_modules/pluscodes/dist/index.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

./node_modules/pluscodes/dist/shorten.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

./node_modules/pluscodes/dist/utils.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
janne commented 2 years ago

Hm, I haven’t seen that before. Have you investigated further what may be causing it? PRs are accepted. ;)

So you get the same error when using both import and require?

ons 23 mars 2022 kl. 20:22 skrev Troy Whiteley @.***>:

Trying to use this but looks like there might be an issue with exports:

import { decode } from "pluscodes";

same issue if I do this too:

const { decode } = require('pluscodes')

warn - ./node_modules/pluscodes/dist/decode.js Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

./node_modules/pluscodes/dist/encode.js Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

./node_modules/pluscodes/dist/expand.js Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

./node_modules/pluscodes/dist/index.js Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

./node_modules/pluscodes/dist/shorten.js Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

./node_modules/pluscodes/dist/utils.js Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

— Reply to this email directly, view it on GitHub https://github.com/janne/pluscodes/issues/12, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAAU6ULIZTWPL7KZH3Y72LVBNVMRANCNFSM5RO5YNWQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

dawnerd commented 2 years ago

Yeah same when using both. I'm no TS expert but looking at the code it seems like it should be fine but I wonder if it's the prepublish compilation. Nextjs shows this error on the frontend: Error: Cannot find module './encode'

I'll dig in some more and see if I find anything

janne commented 2 years ago

Great, thanks, I appreciate it!

ons 23 mars 2022 kl. 23:05 skrev Troy Whiteley @.***>:

Yeah same when using both. I'm no TS expert but looking at the code it seems like it should be fine but I wonder if it's the prepublish compilation. Nextjs shows this error on the frontend: Error: Cannot find module './encode'

I'll dig in some more and see if I find anything

— Reply to this email directly, view it on GitHub https://github.com/janne/pluscodes/issues/12#issuecomment-1076865355, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAAU6QGQBHIULTJNENL2LLVBOIQZANCNFSM5RO5YNWQ . You are receiving this because you commented.Message ID: @.***>

dawnerd commented 2 years ago

Fixed in #13