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

How to add polyfill? #33

Closed
stereobooster opened this issue Jun 2, 2017 · 0 comments
Closed

How to add polyfill? #33

stereobooster opened this issue Jun 2, 2017 · 0 comments

Comments

@stereobooster
Copy link

stereobooster commented Jun 2, 2017

I get this error:

Pushstate server started on port 2999

🕷   Starting crawling http://localhost:2999
Error: Uncaught [TypeError: o.URL.createObjectURL is not a function]
    at reportException (/map-react/node_modules/jsdom/lib/jsdom/living/helpers/runtime-script-errors.js:58:24)
    at processJavaScript (/map-react/node_modules/jsdom/lib/jsdom/living/nodes/HTMLScriptElement-impl.js:130:7)
    at HTMLScriptElementImpl._eval (/map-react/node_modules/jsdom/lib/jsdom/living/nodes/HTMLScriptElement-impl.js:65:7)
    at /map-react/node_modules/jsdom/lib/jsdom/browser/resource-loader.js:31:22
    at Object.check (/map-react/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:89:11)
    at /map-react/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:108:12
    at wrappedEnqueued (/map-react/node_modules/jsdom/lib/jsdom/browser/resource-loader.js:255:16)
    at Request.request [as _callback] (/map-react/node_modules/jsdom/lib/jsdom/browser/resource-loader.js:203:9)
    at Request.self.callback (/map-react/node_modules/request/request.js:188:22)
    at emitTwo (events.js:106:13) TypeError: o.URL.createObjectURL is not a function
    at Object.o.196.../../source/worker (http://localhost:2999/static/js/main.e1936e75.js:1:488554)
    at i (http://localhost:2999/static/js/main.e1936e75.js:1:49924)
    at http://localhost:2999/static/js/main.e1936e75.js:1:49975
    at Object.o.217.../ (http://localhost:2999/static/js/main.e1936e75.js:1:515610)
    at i (http://localhost:2999/static/js/main.e1936e75.js:1:49924)
    at http://localhost:2999/static/js/main.e1936e75.js:1:49975
    at Object.o.205../worker_pool (http://localhost:2999/static/js/main.e1936e75.js:1:494710)
    at i (http://localhost:2999/static/js/main.e1936e75.js:1:49924)
    at http://localhost:2999/static/js/main.e1936e75.js:1:49975
    at Object.o.149.../render/line_atlas (http://localhost:2999/static/js/main.e1936e75.js:1:369730)
✏️   Saving / as /index.html
🕸   Finished crawling.

I can implement polyfil, but not sure how to pass it:

Those are not working:

if (!window.URL) {
  window.URL = { createObjectURL: () => {} }
}

if (!window.URL.createObjectURL) {
  window.URL.createObjectURL = () => {}
}

if (!global.URL) {
  global.URL = { createObjectURL: () => {} }
}

if (!global.URL.createObjectURL) {
  global.URL.createObjectURL = () => {}
}

I suppose I need to patch jsdom?..

Related: alex3165/react-mapbox-gl#240

UPD

Found that this is a bug in jsdom jsdom/jsdom#1721.

Though I do not care that much about actual implementation, even simple fake noop function will do - I do not need to render map on server side, I only need render placeholder for the map, actual map will be rendered on client. Map is for users (with js), server side rendered html is for search bot.

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

No branches or pull requests

1 participant