Describe the bug
I was recently trying to introduce this library to a Vue 3 application that is based on the Vue CLI/Webpack and ran into an error at build time:
Module not found: Error: Default condition should be last one
Whilst the error doesn't mention the launchdarkly-vue-client-sdk package specifically, removing the import of this package also removes the error.
To reproduce
Scaffold a new Vue CLI project using e.g.
yarn global add @vue/cli
vue create test-project
Install this library
yarn add launchdarkly-vue-client-sdk
Import the library in e.g. main.js
import { createApp } from 'vue'
import { LDPlugin } from "launchdarkly-vue-client-sdk";
import App from './App.vue'
createApp(App).use(LDPlugin).mount('#app')
Run or build the app
yarn serve
Expected behavior
The library is able to be imported without throwing errors in Webpack builds
Logs
During a Webpack build:
ERROR Failed to compile with 1 error
error in ./src/main.js
Module not found: Error: Default condition should be last one
ERROR in ./src/main.js 2:0-55
Module not found: Error: Default condition should be last one
webpack compiled with 1 error
SDK version
2.0.2
Language version, developer tools
Node v18.17.0, Webpack 5.88.2, @vue/cli-service 5.0.8
OS/platform
macOS 13.4.1
Additional context
The cause seems to be the exports property in the package.json. I was able to patch the library on my machine by swapping the order of the default and types properties in each section of exports like so:
Describe the bug I was recently trying to introduce this library to a Vue 3 application that is based on the Vue CLI/Webpack and ran into an error at build time:
Whilst the error doesn't mention the
launchdarkly-vue-client-sdk
package specifically, removing the import of this package also removes the error.To reproduce
Import the library in e.g.
main.js
Expected behavior The library is able to be imported without throwing errors in Webpack builds
Logs During a Webpack build:
SDK version 2.0.2
Language version, developer tools Node v18.17.0, Webpack 5.88.2, @vue/cli-service 5.0.8
OS/platform macOS 13.4.1
Additional context The cause seems to be the
exports
property in thepackage.json
. I was able to patch the library on my machine by swapping the order of thedefault
andtypes
properties in each section ofexports
like so:and this resolved the issue.
It looks like the Firebase JS SDK had a similar issue earlier this year:
https://github.com/firebase/firebase-js-sdk/issues/7005