Comments (16)
Thank you! I just updated it and rollup is now working!
from dom-to-image-more.
What method would it be calling to getComputedStyle
from (and/or atob
) ? Just not crashing here doesn't really gain anything, does it?
from dom-to-image-more.
Please retest using just-released v3.1.5, I'm attempting to fall back to globalThis
and really can't find anything better...
from dom-to-image-more.
Here are steps to reproduce...
- Temporarily switch to Node 14 (nvm, brew, whatever you use) and make sure yarn is installed
- Clone the monorepo
git clone https://github.com/nstuyvesant/carbon-charts.git
git checkout fix-pr-1540
git pull
- Navigate to the core package
cd packages/core
- Try to do a build of the core package
npx rollup -c
You will get an error...
[!] ReferenceError: Node is not defined
ReferenceError: Node is not defined
at /Users/nates/dev/rebase/node_modules/dom-to-image-more/src/dom-to-image-more.js:8:26
at Object.<anonymous> (/Users/nates/dev/rebase/node_modules/dom-to-image-more/src/dom-to-image-more.js:1392:3)
at Module._compile (internal/modules/cjs/loader.js:1114:14)
at Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
at Object.require.extensions.<computed> [as .js] (/Users/nates/dev/rebase/node_modules/rollup/dist/bin/rollup:835:17)
at Module.load (internal/modules/cjs/loader.js:979:32)
at Function.Module._load (internal/modules/cjs/loader.js:819:12)
at Module.require (internal/modules/cjs/loader.js:1003:19)
at require (internal/modules/cjs/helpers.js:107:18)
at Object.<anonymous> (/Users/nates/dev/rebase/packages/core/rollup.config.js:13:34)
If you fix that error with the code I submitted for line 8...
const ELEMENT_NODE = typeof Node === 'undefined' ? 1 : Node.ELEMENT_NODE || 1;
do a yarn build
then you will get errors for line 49...
ReferenceError: window is not defined
at /Users/nates/dev/rebase/node_modules/dom-to-image-more/src/dom-to-image-more.js:49:70
at Object.<anonymous> (/Users/nates/dev/rebase/node_modules/dom-to-image-more/src/dom-to-image-more.js:1391:3)
at Module._compile (internal/modules/cjs/loader.js:1114:14)
at Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
at Object.require.extensions.<computed> [as .js] (/Users/nates/dev/rebase/node_modules/rollup/dist/bin/rollup:835:17)
at Module.load (internal/modules/cjs/loader.js:979:32)
at Function.Module._load (internal/modules/cjs/loader.js:819:12)
at Module.require (internal/modules/cjs/loader.js:1003:19)
at require (internal/modules/cjs/helpers.js:107:18)
at Object.<anonymous> (/Users/nates/dev/rebase/packages/core/rollup.config.js:13:34)
This is line 49...
const getComputedStyle = (global && global.getComputedStyle) || (window && window.getComputedStyle) || globalThis.getComputedStyle;
The change made for 3.1.5 replaced my PR with...
const ELEMENT_NODE = (Node && Node.ELEMENT_NODE) || 1;
but that triggers the error. I added this to the line before...
console.log('What is the value of Node?', Node)
and I got an error...
[!] ReferenceError: Node is not defined
ReferenceError: Node is not defined
at /Users/nates/dev/rebase/node_modules/dom-to-image-more/src/dom-to-image-more.js:8:33
I'm not sure why rollup spits out an error as I would have assumed (Node && Node.ELEMENT_NODE)
would short-circuit as Node is false in this case. I only know that my two PRs solved this issue.
Thoughts?
from dom-to-image-more.
I can certainly switch to the uglier syntax. It does seem like the runtime is wrong by not short-circuiting. Ugh. Will see if this can be cleaned better.
from dom-to-image-more.
Yeah - I looked at it for a while scratching my head. I locally upgraded rollup and all plugins but it didn't help. I even switched to node 18.16 - same result.
from dom-to-image-more.
It seems to be an issue with rolllup assuming everything is a module (and thus this
is undefined), which breaks the entire world. This whole thing predates modules and all that stuff...it's just an ife... I reduced it down to the minimum wrapper without the whole thing and get an error when this
is passed in as global
and no error otherwise. See https://rollupjs.org/repl/?version=3.12.1&shareable=JTdCJTIyZXhhbXBsZSUyMiUzQW51bGwlMkMlMjJtb2R1bGVzJTIyJTNBJTVCJTdCJTIyY29kZSUyMiUzQSUyMihmdW5jdGlvbiUyMCgpJTIwJTdCJTVDbiUyMCUyMCUyMCUyMCd1c2UlMjBzdHJpY3QnJTNCJTVDbiU1Q24lMjAlMjBpZiUyMCh0eXBlb2YlMjBleHBvcnRzJTIwJTNEJTNEJTNEJTIwJ29iamVjdCclMjAlMjYlMjYlMjB0eXBlb2YlMjBtb2R1bGUlMjAlM0QlM0QlM0QlMjAnb2JqZ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3RCU1RCUyQyUyMm9wdGlvbnMlMjIlM0ElN0IlMjJvdXRwdXQlMjIlM0ElN0IlMjJmb3JtYXQlMjIlM0ElMjJlcyUyMiU3RCUyQyUyMnRyZWVzaGFrZSUyMiUzQXRydWUlN0QlN0Q=
Related rollup issue rollup/rollup#4834
from dom-to-image-more.
Which means that when rollup tree-shakes this, it assumes this
is undefined
so it KNOWS that the short-circuit doesn't work on global
and thus falls back to the window
even though in actual execution the this isn't undefined, and global
does have a value and it runs correctly :(
Can you tweak your copy of dom-to-image-more to remove the argument in the first line (e.g. delete the global
) and then in the last line, delete the this
argument and see if rollup is happy AND that it runs?
from dom-to-image-more.
This is what the rollupjs test code looks like:
(function () {
'use strict';
if (typeof exports === 'object' && typeof module === 'object') {
module.exports = domtoimage; // eslint-disable-line no-undef
} else {
global.domtoimage = domtoimage;
}
// support node and browsers
const getComputedStyle = (global && global.getComputedStyle) || (window && window.getComputedStyle) || globalThis.getComputedStyle;
const atob = (global && global.atob) || (window && window.atob) || globalThis.atob;
console.log(getComputedStyle(null));
console.log(atob('ff'));
})();
from dom-to-image-more.
I took out global
on line 1 and this
on line 1392. Unfortunately, still getting the error about Node undefined. I assume I'll also get the error for window
as well on 50 and 51 if that one were cleared.
from dom-to-image-more.
That's annoying at best. Rollup's assumption this is a module is at the root of the issue. Tweaks to come, thanks for testing
from dom-to-image-more.
Wish I could say the conversion to vite is ready...
from dom-to-image-more.
So this looks promising https://jsfiddle.net/mjhr2nf1/ aka https://rollupjs.org/repl/?version=3.12.1&shareable=JTdCJTIyZXhhbXBsZSUyMiUzQW51bGwlMkMlMjJtb2R1bGVzJTIyJTNBJTVCJTdCJTIyY29kZSUyMiUzQSUyMihmdW5jdGlvbiUyMCgpJTIwJTdCJTVDbiUyMCUyMCUyMCUyMCd1c2UlMjBzdHJpY3QnJTNCJTVDbiUyMCUyMCUyMCUyMGNvbnN0JTIwRUxFTUVOVF9OT0RFJTIwJTNEJTVDbiUyMCUyMCUyMCUyMCUyMCU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25zb2xlLmxvZyhFTEVNRU5UX05PREUpJTNCJTVDbiUyMCUyMGNvbnNvbGUubG9nKGdldENvbXB1dGVkU3R5bGUpJTNCJTVDbiUyMCUyMGNvbnNvbGUubG9nKGF0b2IpJTNCJTVDbiU3RCkoKSUzQiUyMiUyQyUyMmlzRW50cnklMjIlM0F0cnVlJTJDJTIybmFtZSUyMiUzQSUyMm1haW4uanMlMjIlN0QlNUQlMkMlMjJvcHRpb25zJTIyJTNBJTdCJTIyb3V0cHV0JTIyJTNBJTdCJTIyZm9ybWF0JTIyJTNBJTIyZXMlMjIlN0QlMkMlMjJ0cmVlc2hha2UlMjIlM0F0cnVlJTdEJTdE
from dom-to-image-more.
It does!
from dom-to-image-more.
Looks like you could tweak rollup to know that this
has a value using moduleContext
https://rollupjs.org/configuration-options/#context but I'm going to ship a 3.1.6 with code matching the fiddle now
from dom-to-image-more.
v3.1.6 released
from dom-to-image-more.
Related Issues (20)
- Can I use this library without npm or module? Just plain html HOT 2
- On firefox toPng returns empty image HOT 1
- make it posible to shift
- Icon to image display failed HOT 1
- TypeError: Cannot read properties of undefined (reading 'setProperty')
- Error using toPng with extra quote in HTML
- The internal picture is blank HOT 2
- border HOT 10
- Cannot convert webgl
- Need embed fonts to be optional HOT 5
- Browser crashes when using toPng
- Image is cropped in Firefox HOT 3
- cssRules from google CSS breaking HOT 1
- TypeError:Failed to execute 'readAsDataURL' on 'FileReader' : parameter 1 is not of type 'Blob' HOT 7
- Bug: get wrong pic from image jsp
- domtoimage doesn't work on vector layer
- Exporting blank image when element's parent has visibility hidden
- Dom-to-image conversion results misaligned content in Image for CSS flex styles
- domtoImage converts only first child element when cloneNode(true) is used HOT 1
- Unavaible to override existing CSS style within the adjustClone function HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dom-to-image-more.