{"action":"created","issue":{"url":"https://api.github.com/repos/ivmartel/dwv/issues/531","repository_url":"https://api.github.com/repos/ivmartel/dwv","labels_url":"https://api.github.com/repos/ivmartel/dwv/issues/531/labels{/name}","comments_url":"https://api.github.com/repos/ivmartel/dwv/issues/531/comments","events_url":"https://api.github.com/repos/ivmartel/dwv/issues/531/events","html_url":"https://github.com/ivmartel/dwv/issues/531","id":344176241,"node_id":"MDU6SXNzdWUzNDQxNzYyNDE=","number":531,"title":"No JPEG2000 Support when compiling with webpack","user":{"login":"rrosen","id":1533851,"node_id":"MDQ6VXNlcjE1MzM4NTE=","avatar_url":"https://avatars1.githubusercontent.com/u/1533851?v=4","gravatar_id":"","url":"https://api.github.com/users/rrosen","html_url":"https://github.com/rrosen","followers_url":"https://api.github.com/users/rrosen/followers","following_url":"https://api.github.com/users/rrosen/following{/other_user}","gists_url":"https://api.github.com/users/rrosen/gists{/gist_id}","starred_url":"https://api.github.com/users/rrosen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rrosen/subscriptions","organizations_url":"https://api.github.com/users/rrosen/orgs","repos_url":"https://api.github.com/users/rrosen/repos","events_url":"https://api.github.com/users/rrosen/events{/privacy}","received_events_url":"https://api.github.com/users/rrosen/received_events","type":"User","site_admin":false},"labels":[{"id":159623706,"node_id":"MDU6TGFiZWwxNTk2MjM3MDY=","url":"https://api.github.com/repos/ivmartel/dwv/labels/question","name":"question","color":"d876e3","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/ivmartel/dwv/milestones/35","html_url":"https://github.com/ivmartel/dwv/milestone/35","labels_url":"https://api.github.com/repos/ivmartel/dwv/milestones/35/labels","id":3155726,"node_id":"MDk6TWlsZXN0b25lMzE1NTcyNg==","number":35,"title":"0.24.0","description":"","creator":{"login":"ivmartel","id":398905,"node_id":"MDQ6VXNlcjM5ODkwNQ==","avatar_url":"https://avatars1.githubusercontent.com/u/398905?v=4","gravatar_id":"","url":"https://api.github.com/users/ivmartel","html_url":"https://github.com/ivmartel","followers_url":"https://api.github.com/users/ivmartel/followers","following_url":"https://api.github.com/users/ivmartel/following{/other_user}","gists_url":"https://api.github.com/users/ivmartel/gists{/gist_id}","starred_url":"https://api.github.com/users/ivmartel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivmartel/subscriptions","organizations_url":"https://api.github.com/users/ivmartel/orgs","repos_url":"https://api.github.com/users/ivmartel/repos","events_url":"https://api.github.com/users/ivmartel/events{/privacy}","received_events_url":"https://api.github.com/users/ivmartel/received_events","type":"User","site_admin":false},"open_issues":6,"closed_issues":57,"state":"open","created_at":"2018-03-02T09:52:04Z","updated_at":"2018-08-09T08:59:24Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2018-07-24T19:41:10Z","updated_at":"2018-08-09T12:50:29Z","closed_at":null,"author_association":"NONE","body":"Thanks for providing this amazing project!  We're using dwv in a Rails project and including it via webpack.  Most DICOM's are loading up fine but we're unable to get JPEG2000 support working.  I've added some custom configuration that makes JpxImage and its dependencies available as global variables, but something about the way webpack reads the main dwv.js file prevents it from seeing them.\r\n\r\nHere's some example code\r\nWebpack Config\r\n```javascript\r\nconst webpack = require('webpack')\r\nmodule.exports = {\r\n  plugins: [\r\n    new webpack.ProvidePlugin({\r\n        $: 'jquery',\r\n        jQuery: 'jquery',\r\n        Popper: ['popper.js', 'default'],\r\n        JpxImage: ['dicom/jpeg2000-deps', 'JpxImage'],\r\n        readUint16: ['dicom/jpeg2000-deps', 'readUint16'],\r\n        readUint32: ['dicom/jpeg2000-deps', 'readUint32'],\r\n        log2: ['dicom/jpeg2000-deps', 'log2'],\r\n        ArithmeticDecoder: ['dicom/jpeg2000-deps', 'ArithmeticDecoder'],\r\n    })\r\n  ],\r\n  module: {\r\n    rules: [\r\n      {\r\n        test: require.resolve('dwv/decoders/pdfjs/util.js'),\r\n        use: 'exports-loader?readUint16,readUint32,log2'\r\n      },\r\n      {\r\n        test: require.resolve('dwv/dist/dwv'),\r\n        use: 'imports-loader?this=>window'\r\n      }\r\n    ]\r\n  },\r\n}\r\n\r\n```\r\n\r\njpeg-2000-deps.js\r\n```\r\n// Bundling JpxImage as a module so it can be made available with ProvidePlugin\r\nimport {readUint16, readUint32, log2} from \"dwv/decoders/pdfjs/util\"\r\nconsole.log('readUint32', readUint32)\r\nconsole.log('readUint16', readUint16)\r\nwindow.readUint16 = readUint16.readUint16\r\nwindow.readUint32 = readUint32.readUint32\r\n\r\n\r\nexport const ArithmeticDecoder = require('exports-loader?ArithmeticDecoder!dwv/decoders/pdfjs/arithmetic_decoder');\r\nexport const JpxImage = require('exports-loader?JpxImage!dwv/decoders/pdfjs/jpx');\r\n\r\n\r\nexport {readUint16}\r\nexport {readUint32}\r\nexport {log2}\r\n\r\nwindow.ArithmeticDecoder = ArithmeticDecoder\r\nwindow.JpxImage = JpxImage\r\n```\r\n\r\nour-custom-dicom-viewer.js\r\n```\r\nconsole.log('JpxImage', JpxImage)\r\nconsole.log('readUint16', readUint16)\r\nconsole.log('readUint32', readUint32)\r\nconsole.log('log2', log2)\r\nconsole.log('ArithmeticDecoder', ArithmeticDecoder)\r\n\r\n\r\nconsole.log(\"loaded deps\", window.JpxImage)\r\nconsole.log(\"loading dwv\")\r\nconst dwv = require('dwv/dist/dwv')\r\n\r\n...\r\n```\r\n\r\nWhen I initialize dwv in this way and try to load a JPEG2000 image, it throws the No JPEG2000 support available error.\r\n\r\nI was reading through Issue #399 and noticed the dwv-vue repository you mentioned there as an example of how to load dwv via webpack.  However, I'm noticing the [example application for that repo](https://ivmartel.github.io/dwv-vue/demo/stable/index.html) seems to have similar issues when trying to load JPEG2000 files.  I'm curious what it would take to get JPEG2000 support working in that application."},"comment":{"url":"https://api.github.com/repos/ivmartel/dwv/issues/comments/411746058","html_url":"https://github.com/ivmartel/dwv/issues/531#issuecomment-411746058","issue_url":"https://api.github.com/repos/ivmartel/dwv/issues/531","id":411746058,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMTc0NjA1OA==","user":{"login":"rrosen","id":1533851,"node_id":"MDQ6VXNlcjE1MzM4NTE=","avatar_url":"https://avatars1.githubusercontent.com/u/1533851?v=4","gravatar_id":"","url":"https://api.github.com/users/rrosen","html_url":"https://github.com/rrosen","followers_url":"https://api.github.com/users/rrosen/followers","following_url":"https://api.github.com/users/rrosen/following{/other_user}","gists_url":"https://api.github.com/users/rrosen/gists{/gist_id}","starred_url":"https://api.github.com/users/rrosen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rrosen/subscriptions","organizations_url":"https://api.github.com/users/rrosen/orgs","repos_url":"https://api.github.com/users/rrosen/repos","events_url":"https://api.github.com/users/rrosen/events{/privacy}","received_events_url":"https://api.github.com/users/rrosen/received_events","type":"User","site_admin":false},"created_at":"2018-08-09T12:50:29Z","updated_at":"2018-08-09T12:50:29Z","author_association":"NONE","body":"Thanks for following up :). I got switched me to another project shortly after I filed this issue.  A co-worker picked it up and I think he’s trying a different approach without webpack\n\nRafe\n\n> On Aug 9, 2018, at 5:02 AM, ivmartel <notifications@github.com> wrote:\n> \n> Did you make any progress on this one?\n> \n> —\n> You are receiving this because you authored the thread.\n> Reply to this email directly, view it on GitHub, or mute the thread.\n"}}
{"actor":{"display_login":"rrosen"}}