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

Creating a scoped library fails to load in an application #1064

Closed
johnwebbcole opened this issue Apr 2, 2018 · 6 comments
Closed

Creating a scoped library fails to load in an application #1064

johnwebbcole opened this issue Apr 2, 2018 · 6 comments
Labels

Comments

@johnwebbcole
Copy link

johnwebbcole commented Apr 2, 2018

Version

3.0.0-beta.6

Reproduction link

https://github.com/johnwebbcole/vue-cli-scoped-lib-issue

Steps to reproduce

error loading lib created with vue-cli

Creating a lib with vue-cli works with the demo, but importing into
an app (also created by vue-cli) returns the following:

This dependency was not found:

* @jwc/alib1 in ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"D://src//temp//vue-cli-scoped-lib-issue//app1//node_modules//.cache//cache-loader"}!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/views/Home.vue

To install it, you can run: npm install --save @jwc/alib1

Steps to reproduce

git clone https://github.com/johnwebbcole/vue-cli-scoped-lib-issue.git
cd vue-cli-scoped-lib-issue
cd lib1
npm i
npm run build
cd ..
cd app1
npm i
npm run serve

I'm not sure if I created the lib wrong or imported it wrong.

What is expected?

I'm expecting the library HelloWorld.vue component to be shown.

What is actually happening?

Running the app results in

This dependency was not found:

* @jwc/alib1 in ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"D://src//temp//vue-cli-scoped-lib-issue//app1//node_modules//.cache//cache-loader"}!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/views/Home.vue

To install it, you can run: npm install --save @jwc/alib1
@LinusBorg
Copy link
Member

LinusBorg commented Apr 3, 2018

This doesn't seem to be related to our cli. Your lib's package.json doesn't have a main or files fields which would define the exports of the package, so npm just looks for ` index.js, which doesn't exist.

@johnwebbcole
Copy link
Author

Thanks @LinusBorg , which file(s) do you generally put in main or files? The common.js or the umd.js or both?

It may be nice to have an option on the cli to add the default component to this if you are building a library, or some additional mention in the build types readme.

@LinusBorg
Copy link
Member

LinusBorg commented Apr 3, 2018

  • I would put the /dist in files, maybe also /src.
  • I would put the umd build in the browser field, and the commonjs one in the main field.

@LinusBorg
Copy link
Member

@johnwebbcole So, did that solve your problem?

@johnwebbcole
Copy link
Author

Going to try it this weekend, but I suspect that will fix it.

@johnwebbcole
Copy link
Author

Seems to work! Thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants