smithy-lang / smithy-typescript

Smithy code generators for TypeScript. (in development)
Apache License 2.0
214 stars 80 forks source link

Avoid `re2-wasm` #733

Open riywo opened 1 year ago

riywo commented 1 year ago

While re2-wasm is better than re2, it still requires a trick to run with esbuild that is commonly used by CDK constructs like:

CDK

https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda_nodejs-readme.html#install-modules

This code works:

    const main = new NodejsFunction(this, "MainFunction", {
      entry: "./src/main.ts",
      bundling: {
        nodeModules: ["re2-wasm"],
      },
    });

Projen

https://projen.io/awscdk.html#aws-lambda-functions

No way to workaround as nodeModules type of operation isn't supported yet.


It would be better to use only pure JS packages for SSDK libraries so that esbuild can easily bundle all required files for AWS Lambda without extra effort.

adamthom-amzn commented 1 year ago

In general, I agree; if there's a safe regex implementation in pure JS I'd love to switch to it.

gosar commented 1 year ago

Note earlier discussion on https://github.com/awslabs/smithy-typescript/pull/667

riywo commented 1 year ago

Just curious: If I release a new module just inlining the re2-wasm's WASM binary to avoid runtime file access, is it acceptable?

adamthom-amzn commented 1 year ago

Assuming there's no licensing issues, I don't see a problem with that offhand.