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

Make dwv importable as an es6 module #399

Closed
ivmartel opened this issue Sep 25, 2017 · 11 comments · Fixed by #1331
Closed

Make dwv importable as an es6 module #399

ivmartel opened this issue Sep 25, 2017 · 11 comments · Fixed by #1331
Labels
enhancement New feature or request
Milestone

Comments

@ivmartel
Copy link
Owner

ivmartel commented Sep 25, 2017

DWV must be importable as an es6 module (different than current amd). This is needed for its integration in frameworks such as React or Angular2.

Originates from #373, #367 and #363.

@ivmartel ivmartel added the enhancement New feature or request label Sep 25, 2017
@ivmartel ivmartel added this to the Future milestone Sep 25, 2017
@ivmartel ivmartel changed the title Make dwv importabe as an es6 module Make dwv importable as an es6 module Sep 25, 2017
@ivmartel
Copy link
Owner Author

ivmartel commented Sep 29, 2017

As of today, es6 modules are only supported natively in Chrome (>=61), Opera (>=48) and Safari (>=10.1): see caniuse.com/#feat=es6-module.

For the others:

  • Firefox (55): set dom.moduleScripts.enabled to true in about:config
  • Edge (15): set Experimental JavaScript Features to true in about:flags

@mingjuitsai
Copy link

mingjuitsai commented Dec 15, 2017

Tried to require in Vue with

const dwv = require('dwv');

but getting

Failed to compile.

./node_modules/modernizr/lib/build.js
Module not found: Error: Can't resolve 'generate' in '/Users/mingjuitsai/Sites/mripro/node_modules/modernizr/lib'
 @ ./node_modules/modernizr/lib/build.js 149:2-72
 @ ./node_modules/modernizr/lib/cli.js
 @ ./node_modules/dwv/dist/dwv.min.js
 @ ./src/service/dicomService.js
 @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0&bustCache!./src/components/DicomViewer.vue
 @ ./src/components/DicomViewer.vue
 @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0&bustCache!./src/components/Case.vue
 @ ./src/components/Case.vue
 @ ./src/router/index.js
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js

I'm using vue-cli's webpack template
https://github.com/vuejs-templates/webpack

@BrianMcRails
Copy link

Curious what the priority is with this request, I have a react application that I would love to incorporate your viewer in to. Have you tried this already and run in to issues? If so what were the friction areas? Thinking of forking and trying to make it a react component but I’m curious what problems you’ve run into

@ivmartel
Copy link
Owner Author

ivmartel commented Feb 1, 2018

This issue is on hold, not because of frictions, but because I'm waiting for modules to be supported natively on Firefox so that I do not have to compile each time I want to try the code. Seeing that Mozilla is not moving too much on this, I'll maybe have to change my debug browser...
If you can have a look into it that would be cool! I'm happy to help if you have any troubles.

@Doubledream
Copy link

Tried to require in Vue with

import dwv from 'dwv';

but failed to compile.

These dependencies were not found:

*  in ./~/dwv/dist/dwv.min.js
* i18nextXHRBackend in ./~/dwv/dist/dwv.min.js
* i18nextBrowserLanguageDetector in ./~/dwv/dist/dwv.min.js

@ivmartel
Copy link
Owner Author

ivmartel commented Mar 2, 2018

Ok, moving up the priority list! The plan is to use import/export everywhere and add a webpack step in the build process to create a browser compatible bundle.

@ivmartel
Copy link
Owner Author

A good explanation page on contentful.com: es6-modules-support-lands-in-browsers-is-it-time-to-rethink-bundling (April 2017).

@ivmartel
Copy link
Owner Author

@mingjuitsai, your problem is more related to #467.
@Doubledream, yours is the next one after resolving the modernizr issue and is related to #468.

@ivmartel
Copy link
Owner Author

ivmartel commented Mar 21, 2018

@mingjuitsai & @Doubledream, check out the new dwv-vue repo for an example integration with Vue.js

@ivmartel
Copy link
Owner Author

ivmartel commented Feb 13, 2019

Support update: now on all major browsers apart from IE!
See https://caniuse.com/#feat=es6-module and fundamentals/primers/modules on developers.google.com.

@ivmartel
Copy link
Owner Author

ivmartel commented Dec 9, 2021

@ivmartel ivmartel modified the milestones: Future, 0.32.0 Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants