-
Notifications
You must be signed in to change notification settings - Fork 10
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
[distro request] publish to npm.. #78
Comments
Thanks, Warren, for looking at this. I'd like very much to publish an npm package for Xanado, though at the moment I use github packages rather than npm for my other packages (for no particularly good reason, it was just that the template github actions I used worked that way.) My concern with your proposed changes is the effect on the standalone version, which uses relative paths to find node_modules (there is no server to provide a resolution mechanism.) You probably hadn't noticed that there's a 3.1.0 branch, that has a major refactoring away from requirejs to using esm instead. There are several reasons for doing this, not least that I wanted to split off the storage and dictionary modules for use in other projects, and future-proof things a bit. 3.1.0 also has a number of new features and bugfixes, and I'm in the process of getting it to build a webpacked version of the client code. The obvious question is, how applicable are your proposed changes to the 3.1.0 branch? I can see the .npmignore and package.json changes as desirable, but the npm resolution mechanism is new to me, and it's unclear what it's intended to do. |
I'll be the first to admit that my changes are a total hack.. I haven't used requirejs in many many years.. and they've been happier years for it.
Caveat,
With regard to your concern:
Caveat,
With regard to refactoring:
..then my thoughts are:
In any case, sounds like you have a road-map.. and you're fully on top of things. |
The specific use-case requires that the project is installed below the root, hence the relative paths. Note that my ESM rewrite uses relative paths heavily, though of course they are pre-resolved in the webpack version.
Standalone doesn't use sockets (all comms are entirely within the browser, so the socket methods are stubbed).
Very welcome for that. The Javascript ecosystem is so confused that finding the "right" way to address problems isn't always easy, every commentator seems to have their own approach. I originally used If you would like to try the 3.1.0 branch, then please do -
|
I just published 3.1.0 to npm as @cdot/xanado. I'll be interested to hear how you get on with it! |
Glad to hear it :) I didn't install it yet, but I have a few quick observations that roadblock even bothering to test:
Those two things are the basic plumbing for publishing an executable to npm. edit: results:
..do you have some kind of post-install script? ..which requires another thought.. update: "dependencies": {
"@rwap/jquery-ui-touch-punch": "github:RWAP/jquery-ui-touch-punch",
}, ..why is an npm dependency being resolved from github, rather than the npm repository?
|
update:
|
update:
|
soon...: I'm going to do some housekeeping:
update:
|
I've merged the PR, though there's a problem with socket.io in the build (#85) Two things caught my attention:
Thank you especially for your work on the imports, I'm new to ESM and still learning! |
other thoughts/comments..
|
socket.io comes in two flavours, server side and client side. The one that's failing is the client side (sensibly enough, since we don't webpack the server side ;-) ) There are 3 .md files in the root directory, README, DEVELOPING and CONFIGURATION. I think all three are needed in the npm module. |
regarding the file I'm fairly certain that it isn't used by the server, since my server isn't crashing.. but I just want to be absolutely certain.. is it only ever used client-side.. from within the webpack bundle? if so, then it's safe to revert this one import.. and use a relative path.. to workaround its overly restrictive regarding including markdown in the npm bundle.. you're right, I'm wrong.. there are 3x .md files. rule of thumb, anything that isn't needed to run the code (ie: module/app) should be excluded.. |
I'll update my PR branch.. |
Anything named The README isn't written as the front page for an npm module, it's the front page for the github repository. It might be better to construct a specific readme for the npm, and point to github pages for the full doc. The license is MIT so no problem including some boilerplate. |
I updated my PR branch.. with 2x additional commits.
|
I also:
One thing that's interesting.. which I haven't dug into yet:
|
PS: regarding the README.. this is what it looks like in npm the only difference between our versions is that (in my fork) I tweaked the install instructions to reference my npm repo, rather than upstream. |
webpack does a lot of weird stuff. I've added webpackChunk comments to try and tame it, but I'm not surprised to see it producing yet more module files. The README is fine, it's really not worth faffing about with it. I have a few minor changes pending. |
I get the following error now when trying to run the unpacked code (html/standalone_games.html)
|
isn't that to be expected?
I'd make the analogy that it's like trying to run typescript (or coffeescript) directly in node, The purpose of Webpack is to prepare the (javascript) code to run in a web browser environment; |
fwiw, I asked I can't imagine that your project is unique in wanting to include this code in a client-side bundle. |
Indeed. However one of my goals was a rapid development environment, where no transpilation step was required to run the code, and that's now broken. I would still prefer that, and have the transpiler map the paths, if it's possible to do it that way. I've grown used to the advantages. (I'm aware that an importmap would probably solve the problem). |
if any javascript files are common to both the server and the client, then using node package resolution (which is also used by Webpack) is required.. and it simply won't work in the browser without pre-processing the client-side javascript into a bundle with Webpack. if, however, all of the javascript that runs client-side is completely independent from the code that runs on the server.. then:
|
a better option might be to include links: If you want, I could add this to the repo. |
I'm not going to revert the imports, I prefer them the way you have done it. I'm also not keen on bringing yet another tool into the dev workflow, it's already too baroque IMHO. At least not until we have explored the importmap option (I had it working a while ago, but I was doing it the wrong way round - imposing an importmap on the packed code, rather than removing an importmap required to run the code direct from the repository) |
importmap did the trick. |
you might want to take a peek at the commits that I've made to my dev branch: it took a little trial and error, but..
|
Excellent, good to hear it. I think we're in a good place right now! Curious about the client side bug, but I'll await your analysis. |
oh, nothing major.. just noticed that jQuery was using a bad css selector.. in particular: this is what caught my eye:
I just woke up.. sipping a coffee.. gonna lounge a bit.. haven't looked any farther into it beyond those earlier observations. |
Tsk. I switched several classes over to using id's a while ago, I guess my grepping was less than perfect. Enjoy your coffee! |
I like your idea of using an import map (for each of the 4x html entry points)..
Using a modern web browser that supports ESM, this should be adequate for most local development. |
I tried (1) first, but webpack gave me so much grief that I abandoned it. (2) is fine so long as it's sustainable without too much additional cruft in the build. build/webpack_config.js is too complex already, IMHO. |
darnit..
so.. my plan worked perfectly.. but it's completely useless! |
this is what I settled on.. I ended up producing the import map manually.. |
regarding the frontend jQuery css selectors.. |
regarding a tool to automate the generation of import map(s).. |
Hi. I just found your repo.. and this is great! It's precisely what I was looking for.
To make install easier (for myself).. I forked your repo with the intention to only make a few minor tweaks to 'package.json'.. and publish a snapshot to mirror your most recent release.
Turned out, the code required updates.. to account for broken paths due to assumptions that don't hold (with a global install).
I just wanted to share with you the following links.. in case you should choose to do something similar and publish an official release to npm:
Thanks again for all of your hard work! 😃
The text was updated successfully, but these errors were encountered: