sketch-sh
sketch-sh copied to clipboard
Resolve main entry module from package.json instead of using jsdelivr data
Relevant issue: https://github.com/jsdelivr/jsdelivr/issues/18166
Update
So apparently jsdelivr will minify the main entry file and add .min. in its name. Since we check for the name. And the minified file could saves a lot of bytes and improve parsing speed for the bundler.
So we would save this default file provided by jsdelivr, check with what's provided in main field to see if the different is .min.. If yes then download the minified file.
Description
The bundler needs to know the main entry of a package when working with bare module require statement like require("react"). Currently, I'm relying on jsdelivr's API to query for that information but it could be inaccurate. Since we are going to download package.json anyway, we should resolve this information ourselves.
How
Getting default_file from jsdelivr api is done here
https://github.com/Sketch-sh/sketch-sh/blob/b7cd72552dfe74ee96b3b86eaafe527a61c2becf/client/src/container/Container_fetcher_npm.re#L115
It should be simplify and only returns the files array.
Now add a new decoder for main field here
https://github.com/Sketch-sh/sketch-sh/blob/b7cd72552dfe74ee96b3b86eaafe527a61c2becf/client/src/container/Container_fetcher_npm.re#L165-L166
And use that as value of default_file
I'm trying to run the project on master and getting the following webpack error:
client [master*]yarn start
yarn run v1.17.3
warning ../../../../package.json: No license field
$ webpack-dev-server
/Users/prisc_000/working/SKETCHDEV/sketch-sh/client/node_modules/webpack-cli/bin/config-yargs.js:89
describe: optionsSchema.definitions.output.properties.path.description,
^
TypeError: Cannot read property 'properties' of undefined
at module.exports (/Users/prisc_000/working/SKETCHDEV/sketch-sh/client/node_modules/webpack-cli/bin/config-yargs.js:89:48)
at Object.<anonymous> (/Users/prisc_000/working/SKETCHDEV/sketch-sh/client/node_modules/webpack-dev-server/bin/webpack-dev-server.js:65:25)
at Module._compile (internal/modules/cjs/loader.js:759:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
at Module.load (internal/modules/cjs/loader.js:628:32)
at Function.Module._load (internal/modules/cjs/loader.js:555:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:826:10)
at internal/main/run_main_module.js:17:11
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
➜ client [master*]
In the forum you noted we should run this with yarn. I noticed in https://github.com/Sketch-sh/sketch-sh/blob/master/DEVELOPING.md you use npm. Not sure if this matters.
Is this expected? How should i get the build to run? Thank you.
Also, whenever you run yarn install you always get an error on let-anything package.
SKETCHDEV sketch-sh
➜ sketch-sh [master]ls
CHANGELOG.md Dockerfile Makefile branding docker github now.json.old
DEVELOPING.md LICENSE README.md client docs now.json server
➜ sketch-sh [master]client
➜ client [master]yarn
yarn install v1.17.3
warning ../../../../package.json: No license field
info No lockfile found.
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] 🔍 Resolving packages...
warning reason-loadable > [email protected]: This version of react-dom/server contains a minor vulnerability. Please update react-dom to 16.2.1 or 16.4.2+. Learn more: https://fb.me/cve-2018-6341
warning reason-loadable > react > fbjs > [email protected]: core-js@<2.6.8 is no longer maintained. Please, upgrade to core-js@3 or at least to actual version of core-js@2.
warning @glennsl/bs-jest > jest > jest-cli > jest-config > jest-environment-jsdom > jsdom > [email protected]: use String.prototype.padStart()
warning bundle-buddy > [email protected]: Use portfinder
warning cypress-image-snapshot > term-img > iterm2-version > app-path > execa > [email protected]: cross-spawn no longer requires a build toolchain, use it instead
warning postcss-preset-env > postcss-color-mod-function > postcss-values-parser > [email protected]: I wrote this module a very long time ago; you should use something else.
warning webpack-bundle-analyzer > [email protected]: Switch to the `bfj` package for fixes and new features!
warning webpack-cli > jscodeshift > [email protected]: 🙌 Thanks for using Babel: we recommend using babel-preset-env now: please read https://babeljs.io/env to update!
warning webpack-cli > webpack-addons > jscodeshift > [email protected]: 🙌 Thanks for using Babel: we recommend using babel-preset-env now: please read https://babeljs.io/env to update!
warning webpack-cli > jscodeshift > [email protected]: Package no longer supported. Contact [email protected] for more info.
warning webpack-cli > webpack-addons > jscodeshift > [email protected]: Package no longer supported. Contact [email protected] for more info.
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
warning "@reach/dialog > @reach/[email protected]" has unmet peer dependency "prop-types@^15.6.2".
warning " > [email protected]" has unmet peer dependency "apollo-upload-client@^9.0.0".
warning " > [email protected]" has unmet peer dependency "apollo-utilities@^1.0.16".
warning " > [email protected]" has unmet peer dependency "babel-core@^6.0.0 || ^7.0.0-0".
warning "cypress-image-snapshot > [email protected]" has unmet peer dependency "jest@>=20 <=23".
[4/4] 🔨 Building fresh packages...
[-/8] ⠂ waiting...
[-/8] ⠂ waiting...
[8/8] ⠄ let-anything
[-/8] ⠄ waiting...
error /Users/prisc_000/working/SKETCHDEV/sketch-sh/client/node_modules/let-anything: Command failed.
Exit code: 2
Command: bsb -make-world -backend native
Arguments:
Directory: /Users/prisc_000/working/SKETCHDEV/sketch-sh/client/node_modules/let-anything
Output:
[1/6] Building src/Let_anything.mlast
sh: /Users/prisc_000/working/SKETCHDEV/sketch-sh/client/node_modules/let-anything/node_modules/bsb-native/lib/bs_ppx_tools.exe: No such file or directory
We've found a bug for you!
/Users/prisc_000/working/SKETCHDEV/sketch-sh/client/node_modules/let-anything/src/Let_anything.re
There's been an error running a preprocessor before the compilation of a file.
This was the command:
/Users/prisc_000/working/SKETCHDEV/sketch-sh/client/node_modules/let-anything/node_modules/bsb-native/lib/bs_ppx_tools.exe '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlpp
➜ client [master]
Tried fresh clone. cd client && yarn.
Add let-anything with yarn add let-anything -D due to error on install.
Run an initial bsb build, yarn bs:build.
Start dev server: yarn start.
Same error as above:
➜ client [master*]yarn start
yarn run v1.17.3
warning ../../../../package.json: No license field
$ webpack-dev-server
/Users/prisc_000/working/SKETCHDEV/sketch-sh/client/node_modules/webpack-cli/bin/config-yargs.js:89
describe: optionsSchema.definitions.output.properties.path.description,
^
TypeError: Cannot read property 'properties' of undefined
at module.exports (/Users/prisc_000/working/SKETCHDEV/sketch-sh/client/node_modules/webpack-cli/bin/config-yargs.js:89:48)
at Object.<anonymous> (/Users/prisc_000/working/SKETCHDEV/sketch-sh/client/node_modules/webpack-dev-server/bin/webpack-dev-server.js:65:25)
at Module._compile (internal/modules/cjs/loader.js:759:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
at Module.load (internal/modules/cjs/loader.js:628:32)
at Function.Module._load (internal/modules/cjs/loader.js:555:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:826:10)
at internal/main/run_main_module.js:17:11
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
➜ client [master*]
Will wait on your feedback. Thank you.
@idkjs I'm using yarn, the contributing guide is a little bit outdated. But be sure you check out engine_bs branch ?
Ah, ok. I had it running on that before but didn't realize that is what we were working off of. Thank you.
@idkjs sorry about that. As bucklescript is on development, I didn't get a chance to document it properly
@thangngoc89 i would be happy for you to take a few minutes and walk me through the workflow to get me up and running. Is that possible?
My first question would be, how do i know the Fetch call to JsDeliver is happening? I cant seem to get a Js.log() to run out of the module?
sure. I'll ping you on discord when I'm around
BuckleScript does not exist anymore and I don't think we will have the resources to build a brand new Sketch engine for ReScript anytime soon, so closing related issues.