Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugins do not seem to be recognised or run during build #445

Closed
danielwaghorn opened this issue Mar 8, 2023 · 1 comment
Closed

Plugins do not seem to be recognised or run during build #445

danielwaghorn opened this issue Mar 8, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@danielwaghorn
Copy link
Contributor

Describe the bug
We are compiling TypeScript based functions via the plugin, and our project uses TypeScript paths e.g. @ourcompany/logger to resolve libraries from a separate directory to be used within functions for common functionality.

In order to resolve these paths for bundling we are looking to use the tsconfig-paths plugin, but it appears that the plugins are never passed to esbuild / or executed.

We created a minimal plugin with a console.log in the setup method and it is never invoked. The get plugins() method within the project is definitely returning the plugins attribute from custom.esbuild.plugins and this resolves the file via require to return the plugins object as expected.

It appears however that esbuild never executes with the plugins. The console.log is never invoked.

To Reproduce
Steps to reproduce the behavior. If you have an example repository that would be even better:

The following minimal project was created to verify this behaviour.

serverless.ts

const serverlessConfiguration: ServerlessAzureConfig = {
  service: 'my-api-dev',
  provider: {
    name: "azure",
    region,
    runtime: Runtime.NODE14,
    stage: 'dev',
  },

  functions: {
    health: {
      handler: "api/src/endpoints/health/healthGet.default",
      events: [
        {
          http: true,
          authLevel: "anonymous",
          name: "req",
          methods: ["GET"],
          route: "health",
        },
      ],
    },
  },

  plugins: [
    "serverless-dotenv-plugin",
    "serverless-esbuild",
    "serverless-azure-functions",
  ],

  custom: {
    esbuild: {
      plugins: "esbuild-plugins.js",
    },
  },
};

module.exports = serverlessConfiguration;

esbuild-plugins.js

module.exports = [
  {
       name: "plugin:test",
       setup() {
            console.log('plugin was run');
       },
  },
];

api/src/endpoints/health/healthGet.ts

export default const handler = async (): Promise<void> => {
  context.res = response(200, { health: true });
};

Expected behavior
We expect to see the output from the console.log in the terminal output, but it's never called or invoked. I suspect that the plugins are never presented to esbuild when it is invoked.

Screenshots or Logs
No logs relevant to this issue.

Versions (please complete the following information):

  • OS: MacOS 13.1 (22C65)
  • Serverless Framework Version: 3.28.1
  • Plugin Version: 1.39.0

Additional context
None

@danielwaghorn danielwaghorn added the bug Something isn't working label Mar 8, 2023
@danielwaghorn
Copy link
Contributor Author

Closed in favour of #447.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant