KrysKruk / serverless-import-config-plugin

Split your serverless.yaml config file into smaller modules and import them.
MIT License
10 stars 6 forks source link

.js modules not found #10

Open c-ciobanu opened 4 years ago

c-ciobanu commented 4 years ago

Trying to import a .js file as this

  import:
    - module: config/dynamic.js
      inputs:
        var: test

will throw the following error.

Error: Cannot import config/dynamic.js
Cause: Cannot find module 'config/dynamic.js'

The problem seems to be with the import path, the issue seems to be in this check that will not fail https://github.com/KrysKruk/serverless-import-config-plugin/blob/6df1d651aa03f7e84daa5d24753561df0399fe54/src/index.ts#L60 but the subsequent require will. https://github.com/KrysKruk/serverless-import-config-plugin/blob/6df1d651aa03f7e84daa5d24753561df0399fe54/src/index.ts#L144

Removing the check fixes the problem. A solution would be to bypass the check if the file has a .js ext or completely removing the check but don't know if that impacts something else, didn't dig too much into the code.

ignacioalles commented 3 years ago

Aside from the modifications you've made to make it work, I've found that using an absolute .js path also make it work. It is not very usefull to me but perhaps it might help you.