Open paultranvan opened 2 years ago
Suppose we have a service in targets/services/service.js, that requires a file in targets/services/subdir/file.js, that itself requires a nodejs dependency, e.g. fs. When trying to build the service with cozy-scripts through yarn watch, an error will throw: Module not found: Error: Can't resolve 'fs'. This is because cozy-scripts will only consider js files in targets/services/ but not in subfolder: https://github.com/cozy/create-cozy-app/blob/4b790b81f11c5485a23ad02f7be0bc3dd5219776/packages/cozy-scripts/config/webpack.config.services.js#L15-L19
targets/services/service.js
targets/services/subdir/file.js
fs
yarn watch
Module not found: Error: Can't resolve 'fs'
targets/services/
Hence, any file in subdir/ requiring a nodejs primitive will fail.
subdir/
A workaround would be to recursively find any .js file in targets/services/service.js, but I'm not sure this is the correct approach, as any file will be a new entry: https://github.com/cozy/create-cozy-app/blob/4b790b81f11c5485a23ad02f7be0bc3dd5219776/packages/cozy-scripts/config/webpack.config.services.js#L33
We met this issue with @JulienMirval when trying to use cozy-konnector-libs in a service: https://github.com/JulienMirval/dissec_cozy/blob/ee206472c49c723af630e1d740c1e0384dc73b64/src/targets/services/helpers/model.js#L2
cozy-konnector-libs
Any thoughts?
Suppose we have a service in
targets/services/service.js
, that requires a file intargets/services/subdir/file.js
, that itself requires a nodejs dependency, e.g.fs
. When trying to build the service with cozy-scripts throughyarn watch
, an error will throw:Module not found: Error: Can't resolve 'fs'
. This is because cozy-scripts will only consider js files intargets/services/
but not in subfolder: https://github.com/cozy/create-cozy-app/blob/4b790b81f11c5485a23ad02f7be0bc3dd5219776/packages/cozy-scripts/config/webpack.config.services.js#L15-L19Hence, any file in
subdir/
requiring a nodejs primitive will fail.A workaround would be to recursively find any .js file in
targets/services/service.js
, but I'm not sure this is the correct approach, as any file will be a new entry: https://github.com/cozy/create-cozy-app/blob/4b790b81f11c5485a23ad02f7be0bc3dd5219776/packages/cozy-scripts/config/webpack.config.services.js#L33We met this issue with @JulienMirval when trying to use
cozy-konnector-libs
in a service: https://github.com/JulienMirval/dissec_cozy/blob/ee206472c49c723af630e1d740c1e0384dc73b64/src/targets/services/helpers/model.js#L2Any thoughts?