-
-
Notifications
You must be signed in to change notification settings - Fork 3.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
ci(): Node build #8632
ci(): Node build #8632
Conversation
due to FabricObject to canvas method
let me know when you are done so i can play with the exports and examples. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed the output files to index
and index.node
This PR ןד ready apart from TS not recognizing
import * as fabric from 'fabric/node'
I tried many things and read a lot of stuff online and wasted 3-4 hours on it so I am giving up
Seems that it is another TS limitation
Tried declaring modules in d.ts file with no success...
Added paths
in tsconfig after reading about it and seeing rxjs that has that config and imports work for it but couldn't get it to work for fabric (However I might have managed to get it working but symlinking is known מםא to work is this cases and I didn't test it w/o symlinks)
Let's move on and get back to it.
You can play in v6-sandbox
branch which is up to date with this PR
We need to consider removing index.ts so vscode and TS don't import that for types. It isn't needed anyways. It is simply an alias for fabric.ts |
A workaround for type recognition of |
Well I don't know. I am leaving as is since it is clearly a TS bug. paths: {
'fabric/node': './node_modules/fabric/dist/index.node'
} |
looking in a couple of things for node, but in general this PR is good as it is. |
Sharing some research on typing submodules: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i that is the only thing we need to change and we are good to go
@@ -76,6 +76,7 @@ | |||
"@rollup/plugin-terser": "^0.3.0", | |||
"@rollup/plugin-typescript": "^11.0.0", | |||
"@types/fs-extra": "^9.0.13", | |||
"@types/jsdom": "^20.0.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either use jsdom types for 19 or upgrade jsdom to 20
env = value; | ||
}; | ||
|
||
export const getEnv = () => env || getBrowserEnv(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i m lost a bit on this thing here.
Why again do we need an index file and the setEnv part if we could use the same trick with isInitialized
Seems like we want fabric importing from here, but having the import statement over the env/node file create a value with setEnv that nullify the browser env. Is that correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why again do we need an index file and the setEnv part if we could use the same trick with isInitialized
I am not sure what you are suggesting
Seems like we want fabric importing from here, but having the import statement over the env/node file create a value with setEnv that nullify the browser env. Is that correct?
Yes, correct.
I will some comments
i can get the node types recognized if i used them from their folder right away. |
b326dd6 fixes |
regarding isLikelyNode, i can. count only 4 usage in the codebase. Webglprobe, objectCaching, parseSVG, and cleanUpJsdomNode Now my opinion is that cleanUpJsdomNode and webglProbe and objectCaching are env dependendant, and if we don't like the boolean, getEnv could return:
parseSVG should be tested to see if this bug is still actual or isn't anymore. Do you have a totally different idea? We can also just rename the boolean, removing the isLikely part, but the bug in parseSVG could be checked anyway if is still actual |
I wanted to add some comments. I will in the follow up. I agree with what you suggest. Env cleanup is just a jsdom thing. I vote to remove jsdom and extend the node env to support what we really need. Renaming the boolean is good also, but I prefer removing it. For tests we can add a global flag in the config files. |
Motivation
#8208 + supporting SSR out of the bbox
Description
continues #8622 with additional config changes and fixes to support SSR and remove
require
calls and awkwardness from fabric env setup.After this is merged we can change to node index file.
Changes
view the diff from #8622 v6-package-testing...node-build
getEnv
during importcloneWithoutData
return value to match node StaticCanvas (or any subclass)isLikelyNode
because we are now certain it is node. Haven't done it yet so the PR isn't polluted. Give me a green light and I will (or in a follow up)created index files for exports, put them under the folders and renamed to index. If you don't want the name to be index to avoid importing from it (though I don't really understand why) revert 8829519 and naming will be restored.reverted e4fab60Gist
In order to support SSR
getEnv
can't be called when importing fabric because then env is setup incorrectly because at the time of importing window/document are undefined and only when canvas is initialized then env should be setup.In Action
Test this config by doing the following:
checkout
v6-sandbox
run
npm run sandbox start -- -t next
You will see in the browser tab 2 canvases, one with next SSR dynamic import and one plain and simple, both working.
In the node tab hit the download buttons to see the node build in action
OR run in gitpod