-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
pack dependency #827
Comments
Where is this file located - wpdf.js? You could import it at the top no? import "path-to/wpdf.js" |
its another pack file. Doesn't |
This feels like a question better suited for the pdf.js repo and I don't know much about the project myself, but I'll take a stab: The pdf.js webpack example assumes the src is known ahead of time. I don't believe you can reference
|
I was able to get it working by removing my wpdf.js pack file, and using worker-loader* to create one on the fly. The wpdf.js is no longer in the webpacker manifest, but that is fine because I shouldn't need to reference it anywhere else. // no longer a js.erb file - just javascript
require('pdfjs-dist')
var worker = require("worker-loader?name=wpdf.[hash].js!pdfjs-dist/build/pdf.worker")
// ugly, but I just need the path to the file
var workerPath = (/wpdf\.\w+\.js/i).exec(worker.toString())
PDFJS.workerSrc = "/packs/" + workerPath[0] Thanks for your suggestions * using the |
Somewhat different, but related issue; again this is about js files depending on one another. Now that Webpacker is the default JavaScript bundler for Rails, I am struggling to hoist my old Old workflow with SprocketsConsider a javascript file for the main thread (let's call it #= depend_on awesome-worker
worker = new Worker "<%= asset_path('awesome-worker') %>"
… then in #= depend_on mini-js-lib
importScripts "<%= asset_path('mini-js-lib') %>"
… Any edits to
Webpack workflowThe closest out-of-the-box solution i can find would be to use worker-loader, abandon
import awesomeWorker from "worker-loader!./awesome-worker"
worker = new awesomeWorker()
…
import miniJsLib from 'mini-js-lib'
… OR… Write a new PluginSomething more elegant would be to fork Google's worker-plugin to handle worker = new Worker("./awesome-worker")
…
importScripts("./mini-js-lib")
… I am not opposed to writing a new webpack plugin, but I can't imagine that I am the only one with this issue. Am I missing something? - Is there a simpler solution to this problem? |
Consider this mozilla pdf.js pack file in packs/pdf.js.erb:
webpacker:compile
fails because wpdf is not yet compiled:In sprockets world I would include
depend_on
at the top file, and reference asset with<%= asset_path('required-asset.js') %>
Is there a way for a pack to reference and depend on another pack?
The text was updated successfully, but these errors were encountered: