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

Esbuild Plugin Error Using @anatine/esbuild-decorators #396

Open
yotamishak opened this issue May 9, 2024 · 1 comment
Open

Esbuild Plugin Error Using @anatine/esbuild-decorators #396

yotamishak opened this issue May 9, 2024 · 1 comment
Assignees

Comments

@yotamishak
Copy link

yotamishak commented May 9, 2024

Hello,

using sst - 0.0.359

I can also confirm i get the same error with https://github.com/thomaschaaf/esbuild-plugin-tsc

while trying to get a POC running Nestjs in ion to potentially replace serverless framework.

We currently use Nestjs on serverless framework, using esbuild using the following esbuild config

 esbuild: {
      bundle: true,
      minify: false,
      sourcemap: true,
      target: 'node20',
      platform: 'node',
      concurrency: 10,
 
      packager: 'pnpm',
      exclude: [
        '@aws-sdk/*',
        '@nestjs/microservices',
        'pg-native',
        'nats',
        'mqtt',
        'kafkajs',
        'grpc',
        'apollo-server-express',
        'apollo-server-fastify',
        'class-transformer/storage',
        'cache-manager',
        '@nestjs/websockets/socket-module',
        'class-transformer',
        'class-validator',
      ],
      plugins: 'esbuild.plugins.js',
    },

esbuild.plugins.js

const { esbuildDecorators } = require('@anatine/esbuild-decorators');

const esbuildPlugins = [esbuildDecorators()];

module.exports = esbuildPlugins;

using nodejs install i was able to replicate the exclude functionality above
sst.config.ts

///
import { esbuildDecorators } from '@anatine/esbuild-decorators';
 
export default $config({
  app(input) {
    return {
      name: 'nest-ion',
      removal: input?.stage === 'production' ? 'retain' : 'remove',
      home: 'aws',
    };
  },
  async run() {
    const api = new sst.aws.ApiGatewayV2('MyApi');
    api.route('ANY /{proxy+}', {
      handler: 'src/index.handler',
      nodejs: {
        install: [
          '@nestjs/microservices',
          'pg-native',
          'nats',
          'mqtt',
          'kafkajs',
          'grpc',
          'apollo-server-express',
          'apollo-server-fastify',
          'class-transformer/storage',
          'cache-manager',
          '@nestjs/websockets/socket-module',
          'class-transformer',
          'class-validator',
        ],
        esbuild: {
          plugins: [esbuildDecorators()],
        },
      },
    });
  },
});

but when i run sst dev (while try to use the esbuild plugin) i get the following error

~ Deploying
 
| Error ReferenceError: __filename is not defined in ES module scope
| at isFileSystemCaseSensitive (file:///Users/yotam/dev/nest-ion/node_modules/.pnpm/typescript@4.9.5/node_modules/typescript/lib/typescript.js:7301:45)
| at getNodeSystem (file:///Users/yotam/dev/nest-ion/node_modules/.pnpm/typescript@4.9.5/node_modules/typescript/lib/typescript.js:7066:45)
| at file:///Users/yotam/dev/nest-ion/node_modules/.pnpm/typescript@4.9.5/node_modules/typescript/lib/typescript.js:7535:19
| at file:///Users/yotam/dev/nest-ion/node_modules/.pnpm/typescript@4.9.5/node_modules/typescript/lib/typescript.js:7542:5
| at node_modules/.pnpm/typescript@4.9.5/node_modules/typescript/lib/typescript.js (file:///Users/yotam/dev/nest-ion/node_modules/.pnpm/typescript@4.9.5/node_modules/typescript/lib/typescript.js:7557:1)
| at __require2 (file:///Users/yotam/dev/nest-ion/.sst/platform/eval/eval-1715262938079.mjs:24:50)
| at node_modules/.pnpm/@anatine+esbuild-decorators@0.2.19_esbuild@0.21.1/node_modules/@anatine/esbuild-decorators/src/lib/esbuild-decorators.js (file:///Users/yotam/dev/nest-ion/node_modules/.pnpm/@anatine+esbuild-decorators@0.2.19_esbuild@0.21.1/packages/esbuild-decorators/src/lib/esbuild-decorators.ts:4:1)
| at __require2 (file:///Users/yotam/dev/nest-ion/.sst/platform/eval/eval-1715262938079.mjs:24:50)
| at node_modules/.pnpm/@anatine+esbuild-decorators@0.2.19_esbuild@0.21.1/node_modules/@anatine/esbuild-decorators/src/index.js (file:///Users/yotam/dev/nest-ion/node_modules/.pnpm/@anatine+esbuild-decorators@0.2.19_esbuild@0.21.1/packages/esbuild-decorators/src/index.ts:1:1)
| at __require2 (file:///Users/yotam/dev/nest-ion/.sst/platform/eval/eval-1715262938079.mjs:24:50)
@thdxr thdxr self-assigned this May 9, 2024
@yotamishak
Copy link
Author

yotamishak commented May 15, 2024

i created a reproducible example without all the nestjs noise.

https://github.com/yotamishak/ion-esbuild-decorators

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants