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

Trouble importing to esbuild.config.js from an internal monorepo package #530

Closed
bryansoftdev opened this issue Feb 26, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@bryansoftdev
Copy link

bryansoftdev commented Feb 26, 2024

Describe the bug
I'm trying to import some of the config from a pnpm workspace internal package. But the import doesn't seem to be resolving correctly in the config file. It resolves fine in my app's index.ts file.

To Reproduce

  1. Use config option in ./apps/service/serverless.yml
  custom:
    esbuild:
      config: './esbuild.config.js'
  1. Export something in /packages/sentry-wrapper/index.ts
const sentryConfig = {
  sourcemaps: true,
  plugins: [ sentryEsbuildPlugin({
    ...
  })],
};

export default {
  sentryConfig
};
  1. Try to import it in ./apps/service/esbuild.config.js
const { sentryConfig } = require('sentry-wrapper');

module.exports = () => ({
  ...sentryConfig,
  exclude: ['@aws-sdk'],
  watch: {
    pattern: ['./**/*.(js|ts)', '../../packages/**/*.ts'],
  },
});

  1. Run serverless deploy Cannot find module 'sentry-wrapper'

Expected behavior
Should be able to import from internal packages.

Versions (please complete the following information):

  • OS: Mac
  • "serverless": "^3.35.2"
  • "serverless-esbuild": "^1.48.4"

Thanks for any help. (Any ideas on other ways I can get this working?)

@bryansoftdev bryansoftdev added the bug Something isn't working label Feb 26, 2024
@bryansoftdev
Copy link
Author

bryansoftdev commented Feb 28, 2024

I figured it out. Now using CommonJS for exports instead of ESM.

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