Fails to compile: export 'fetchFromApi' was not found in '@microlink/mql
skatkov opened this issue · comments
Bug Report
Current Behavior
I'm running ./bin/webpack --progress
in a project, but webpack fails to compile with following errors:
ERROR in ./node_modules/@microlink/react/dist/microlink.m.js 6:0-46
"export 'fetchFromApi' was not found in '@microlink/mql'
@ ./node_modules/@microlink/vanilla/src/index.js
@ ./app/javascript/sprinkles/collections.js
@ ./app/javascript/sprinkles/index.js
@ ./app/javascript/index.js
@ ./app/javascript/packs/application.js
ERROR in ./node_modules/@microlink/react/dist/microlink.m.js 1669:62-74
"export 'fetchFromApi' was not found in '@microlink/mql'
@ ./node_modules/@microlink/vanilla/src/index.js
@ ./app/javascript/sprinkles/collections.js
@ ./app/javascript/sprinkles/index.js
@ ./app/javascript/index.js
@ ./app/javascript/packs/application.js
ERROR in ./node_modules/@microlink/react/dist/microlink.m.js 768:9-20
"export 'getApiUrl' (imported as 'getApiUrl$1') was not found in '@microlink/mql'
@ ./node_modules/@microlink/vanilla/src/index.js
@ ./app/javascript/sprinkles/collections.js
@ ./app/javascript/sprinkles/index.js
@ ./app/javascript/index.js
@ ./app/javascript/packs/application.js
Expected behavior/code
Webpack compiles properly
Possible Solution
My solution was to use older version, tricky part was that transitive dependencies are really lax and they kept pulling broken version into my build. So this is end result that worked for me:
"dependencies": {
"@microlink/react": "4.2.2",
"@microlink/vanilla": "4.2.2",
},
"resolutions": {
"@microlink/react": "4.2.2"
}
That "resolutions" part makes sure that new version will not brought through transitive dependencies. Work swith yarn, not sure about npm :)
Additional context/Screenshots
npm: 6.11.3
webpack 4.41.2
yarn.lock
"@microlink/mql@~0.5.10":
version "0.5.10"
resolved "https://registry.yarnpkg.com/@microlink/mql/-/mql-0.5.10.tgz#01254834c99fb14b7e6f229270243b9073b9af1f"
integrity sha512-CRpnEL+ZwIghKJ9gW3C0JmxvOj8SBjvtpPyrfoEUUoIICLb+0L8QyDt2xGru/wnN83bomZxra97xkdogrDvRzA==
dependencies:
flat "~5.0.0"
got "~9.6.0"
is-url-http "~1.2.4"
ky "~0.15.0"
ky-universal "~0.3.0"
qss "~2.0.3"
whoops "~4.0.2"
"@microlink/react@^4.3.2":
version "4.3.2"
resolved "https://registry.yarnpkg.com/@microlink/react/-/react-4.3.2.tgz#1f50e4460b9278b9265a702c2cd65931a9fbbee3"
integrity sha512-YgzOSMhMSRhT8d/wxHuFV2erygFLDzIgoLSULwk/OmAUFjwI/j5pwz+IWn0qQLt3pNzgPWvSC+hX6FmkCsQB+Q==
dependencies:
"@microlink/mql" "~0.5.10"
nanoclamp "~1.2.11"
"@microlink/vanilla@^4.2.2":
version "4.3.2"
resolved "https://registry.yarnpkg.com/@microlink/vanilla/-/vanilla-4.3.2.tgz#87c6082c2df9d30b5a1d467026e2e8b58f2bbe07"
integrity sha512-JSldyPcJbEiMwqYb4h4TBHUgVjyet0iMwMTbrdRVrc7VQq088HVRFFVFl/zqe6e8CrKllUckzFOVergFh21gSQ==
dependencies:
"@microlink/react" "^4.3.2"
First, why are you adding @microlink/vanilla
as a dependency? If you are adding it because you need it as part of your project that's okay, but otherwise, you don't need it.
In fact @microlink/vanilla
is created using @microlink/react
: https://github.com/microlinkhq/sdk/blob/master/packages/vanilla/src/index.js#L3
The thing happening there is, the vanilla bundle doesn't include global dependencies, so they need to be injected. See the scripts on this codesandbox:
https://codesandbox.io/s/nervous-cherry-o92r2y4q9z
If you want to use @microlink/vanilla
from the code probably you need to install @microlink/mql
since that's the thing webpack is saying, it can't resolve that dependency because it's missing.
But as I said, is your objective is to use @microlink/react
, you don't need to do that!
I get the same error just following the docs here: https://microlink.io/docs/sdk/integrations/react/