Javascript Dev: Our naming conventions cause issues with require() #6344
-
Something I have been struggling with recently. Our conventions of placing TW's module system allows requiring modules with a relative path, i.e. "./name" and uses this to build a path from the current context/module. It then tries to load code from that tiddler. Most plugins use the In node, a I could simply name the Yjs library I was considering experimenting by changing I think this would really simplify how people can structure their plugins, so that even if they use the What do you all think? |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 2 replies
-
Hrm, that causes a bunch of issues... scratch that change.... |
Beta Was this translation helpful? Give feedback.
-
My primary issue is that I have 3rd party libraries that depend on other 3rd party libraries. Any time I
etc, etc. Same thing with the WS (websockets) library. I can import these no problem, but if I use the standard |
Beta Was this translation helpful? Give feedback.
-
I have figured out one of the issues. I have gone to just naming the tiddlers after their base Node.js/NPM package name in the So, instead of This breaks the Node.js style requires in a lot of 3rd party packages. @Jermolene any ideas here? can we adjust |
Beta Was this translation helpful? Give feedback.
-
Reading through this as it seems related: #2817 I am trying to structure a package that will be able to use npm modules as sources, using well structured |
Beta Was this translation helpful? Give feedback.
-
I'm learning more about node modules, how package.json works and other things that are helping with this. I may end up making my realtime multiplayer server-code a stand-along node package that requires TW as a dependency. |
Beta Was this translation helpful? Give feedback.
-
I think you should use rollup or esbuild or webpack, and use import statement. Then all import will only happened at buold time, and wont affect tw runtime. |
Beta Was this translation helpful? Give feedback.
-
This discussion can be "closed". I actually learned a lot, and have managed to implement installing TW plugins as NPM modules, with their own sub-folder that has a |
Beta Was this translation helpful? Give feedback.
I think you should use rollup or esbuild or webpack, and use import statement. Then all import will only happened at buold time, and wont affect tw runtime.