Skip to content

Print JS has window in dist/print.js and therefor doesnt work on SSR #542

@daphnesmit

Description

@daphnesmit

HI!

I am using print js and its great!
The only problem I am facing is that the dist/print.js had on line 10 a window declaration which will fail on ssr when trying to load the site with a printjs import.

First 10 lines of dist/print.js

(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory();
	else if(typeof define === 'function' && define.amd)
		define([], factory);
	else if(typeof exports === 'object')
		exports["printJS"] = factory();
	else
		root["printJS"] = factory();
})(window, function() {
return /******/ (function(modules) { 

According to this site https://zenuml.medium.com/window-is-undefined-in-umd-library-output-for-webpack4-858af1b881df

a fix would be adding globalObject this. I will check further but thought i'd create an issue already!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions