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

Unable to import from library #367

Closed
andkhong opened this issue Jul 5, 2017 · 9 comments
Closed

Unable to import from library #367

andkhong opened this issue Jul 5, 2017 · 9 comments
Labels
question Further information is requested
Milestone

Comments

@andkhong
Copy link

andkhong commented Jul 5, 2017

import dwv from 'dwv';
./~/dwv/dist/dwv.min.js
Module not found: Empty dependency (no request)

I am unable to import with front end libraries such as React/Vue

Is it possible for you to incorporate RequireJS and/or Browserify which will enable Client side use?

@ivmartel ivmartel added the question Further information is requested label Jul 6, 2017
@ivmartel ivmartel added this to the 0.21.0 milestone Jul 6, 2017
@ivmartel
Copy link
Owner

The code is modularised using this intro.js file. It should work with RequireJS.
Not sure what it is missing to import it in React/Vue... How does their import work?

@LaedaSt
Copy link

LaedaSt commented Sep 10, 2017

UP!
I'm developing an application on Laravel and I encountered the same problem. Standard methods, such as npm install / update, adding libraries React, Vue, Require, also did not solve the problem. Can someone else come across this and solve the problem?

@ivmartel
Copy link
Owner

Ok, it's maybe time to use es6 import and package dwv using webpack instead of these manual scripts. This should solve this import error.

@ivmartel
Copy link
Owner

While waiting for an es6 update, I think I have a quick fix. You can use the webpack exports-loader to package dwv in a way you can import it.
Install it and then, in your code, import using:

// eslint-disable-next-line import/no-webpack-loader-syntax
import dwv from 'exports-loader?dwv!dwv';

The comment line disables the default linting error preventing the use of webpack loaders.

I tried it in a react environment, I hope it works in others... This solves the import error, I'll try to create a dwv-react viewer to check if there could be others...

@ivmartel
Copy link
Owner

I forgot to say that the fix I describe above works for the non modularised dwv, meaning stripped of the intro.js and outro.js...

@ivmartel
Copy link
Owner

A dwv-react viewer is a bit tricky... It needs to import the appgui file which is not 'importable' as it is. Not sure what's the best way to go forward...

@ivmartel
Copy link
Owner

I created an issue for this (#399). Please comment there if you need.

@ivmartel
Copy link
Owner

Maybe not related to es6 modules but more to modernizr #467 and AMD #468 issues...

@ivmartel
Copy link
Owner

🚀 Got it working! Check out the new dwv-react and dwv-vue repos.

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

No branches or pull requests

3 participants