script.js icon indicating copy to clipboard operation
script.js copied to clipboard

consuming with webpack for node.js and isomorphic

Open joshunger opened this issue 9 years ago • 1 comments

Q. We're using script.js and webpack to bundle for both the browser and node.js. What is the best approach here to provide a fallback?

Current, as expected, I get this error (as expected) -

  var doc = document
            ^

ReferenceError: document is not defined

Which is from this code -

})('$script', function () {
  var doc = document

joshunger avatar Aug 01 '16 22:08 joshunger

document and head variables declaration only need to be moved to the create() function (so improt/require works in server side)

Kronuz avatar Sep 06 '17 23:09 Kronuz