Closed siefkenj closed 2 years ago
Since I still don't have a working sage build, I cannot test the make script, so hopefully you can test it for me. It works with the build.zip
file you provided.
I get adding vendor
prefix, but could you please explain why a bunch of new named modules were added and why quotes were removed in some cases?
I get adding
vendor
prefix, but could you please explain why a bunch of new named modules were added and why quotes were removed in some cases?
Oh, sorry! I used Prettier to format the file. It normalizes all quotes to "
. I can revert them if you like.
There actually weren't any new deps added. r.js
would search the local directory for imported files not listed in the deps. After moving them to vendor
, these imports failed, so I added them explicitly. Now the deps list + non-vendor js/html files should be the only things needed to build sagecell. (Currently a ton of uneeded files are copied into vendor
by the Makefile. I am looking at trimming that down.)
Almost everything is coming from cp -a $(SAGE_VENV)/lib/python3.9/site-packages/notebook/static
the rest of dependencies are individual files. If we are to do the separation, wouldn't it be more natural then to have a separate path for this directory and another common one for the rest?
Regarding quotes I am confused by
jquery: "vendor/components/jquery/jquery.min",
"jquery-ui": "vendor/components/jquery-ui/jquery-ui.min",
I get that one can use single or double and perhaps it is prettier to use the same quotes. But why jquery
has no quotes at all anymore, while jquery-ui
does have them???
Almost everything is coming from
cp -a $(SAGE_VENV)/lib/python3.9/site-packages/notebook/static
the rest of dependencies are individual files. If we are to do the separation, wouldn't it be more natural then to have a separate path for this directory and another common one for the rest?
Conceptually that works, but do you think this would be helpful? I think the most important thing is that devs know what code they are responsible for (i.e., they know to completely ignore the vendor
dir).
I get that one can use single or double and perhaps it is prettier to use the same quotes. But why
jquery
has no quotes at all anymore, whilejquery-ui
does have them???
Javascript objects do not require quoted strings unless the key contains a non-letter/non-number character. Usually keys are not quoted unless they need to be.
Ah! Thank you for your patience in explaining JS basics ;-)
Regarding knowing what developers are responsible for - they should completely ignore the current build
directory, all SageMathCell JavaScript code is contained in js
directory. build
is used to pile up everything together and build a single file, which is then copied into static
. So if the point is clear separation of our code vs dependencies it seems to me that it is already achieved, although apparently it is not clearly explained. Perhaps instead of moving files around we should add something to the documentation?
Perhaps instead of moving files around we should add something to the documentation?
I think the files should still be put in vendor
. The current build system is pretty unusual. Typically non-vendor files are not copied before a build. Instead the JS compiler works with the files in the js
directory directly and outputs the result in a build
directory. My hope is to unwind the Makefile a bit so that the JS can be build this way. But, I wanted to do incremental steps rather than presenting you with a big diff.
There are other benefits to the vendor/
approach
build.js
.node_modules
approach of npm
. Half of the deps (e.g. jQuery, undescore and friends) can be grabbed by running npm install jquery underscore
. Only the sage-specfic deps would need to be copied. In this way, the vendor/
folder would act like the sage-specific node_modules
folder.Makes sense - thank you once again for your patient explanations!
No problem!
My next plan is to sort out some of the global variable initialization which will pave the way to using ES imports instead of requirejs.
Copy all external JavaScript into
build/vendor
instead of directly intobuild/
. This should make it easier to separate internal vs external dependencies during development.