hammady / wwpray

A website that shows the prayer times for a preconfigured list of masjids in a tabular format. Visitors can subscribe for email notifications.
https://wwpray.net
MIT License
1 stars 0 forks source link

Use npm workspaces to combine package-json files #35

Closed fayez-nazzal closed 1 year ago

fayez-nazzal commented 1 year ago

Add svelte package to the workspace property of wwpray-generator package.json file. This way:

Made as the first step for #20

fayez-nazzal commented 1 year ago

@hammady Will that work for the first step of #20 ?

hammady commented 1 year ago

@fayez-nazzal will definitely give it a try!

fayez-nazzal commented 1 year ago

@hammady I updated the PR description to add one missing detail. What is the node version are you using?

hammady commented 1 year ago

nodejs18.x I'm not sure if it will work on AWS Lambda because we don't install requirements manually so we have no control over the command to run.

fayez-nazzal commented 1 year ago

@hammady Can you tell me what commands are run automatically by lambda?

hammady commented 1 year ago

@fayez-nazzal wait, I thought you meant we need to invoke the npm install by specifying the workspace name. I didn't realize npm will pick it up automatically! I just realized that you were referring to the npm run commands if we want to invoke scripts in the svelte directory! So I refactored the generation to build the workspace from the root directory, please check the commits. I am still unable to get it to work on aws. Local build still works after these refactorings. I think the next step is to replace the npm build command by the JS API building?

hammady commented 1 year ago

So to make it clear, npm install picked up the nested dependencies but the build command failed with the below:

Generating data into /tmp/dist...
npm verb cli /var/lang/bin/node /var/lang/bin/npm
npm info using npm@9.6.7
npm info using node@v18.17.1
npm verb title npm run build
npm verb argv "run" "build" "--workspace" "svelte" "--cache" "/tmp/cache" "--loglevel" "verbose"
npm verb logfile logs-max:10 dir:/tmp/cache/_logs/2023-10-18T04_58_28_987Z-
npm verb logfile /tmp/cache/_logs/2023-10-18T04_58_28_987Z-debug-0.log
> svelte@0.0.1 build
> vite build
npm http fetch GET 200 https://registry.npmjs.org/npm 337ms (cache miss)
(node:34) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/tmp/generator/node_modules/.bin/vite:2
import { performance } from 'node:perf_hooks'
^^^^^^
SyntaxError: Cannot use import statement outside a module
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1178:20)
at Module._compile (node:internal/modules/cjs/loader:1220:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47
Node.js v18.17.1
npm ERR! Lifecycle script `build` failed with error: 
npm ERR! Error: command failed 
npm ERR!   in workspace: svelte@0.0.1 
npm ERR!   at location: /tmp/generator/svelte 
npm notice 
npm notice New major version of npm available! 9.6.7 -> 10.2.0
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.2.0>
npm notice Run `npm install -g npm@10.2.0` to update!
npm notice 
npm verb exit 1
npm verb code 1
hammady commented 1 year ago

@hammady Can you tell me what commands are run automatically by lambda?

It is just the npm install. This passes. Now we are in the build stage and it fails.

fayez-nazzal commented 1 year ago

@hammady JS build is made in #37, it's based on this PR