Skip to content

Comments

Add SST plugin#985

Closed
BryanCrotazGivEnergy wants to merge 3 commits intowebpro-nl:mainfrom
BryanCrotazGivEnergy:main
Closed

Add SST plugin#985
BryanCrotazGivEnergy wants to merge 3 commits intowebpro-nl:mainfrom
BryanCrotazGivEnergy:main

Conversation

@BryanCrotazGivEnergy
Copy link

Added a v1 sst plugin.

Loads lambda handlers from:
/handlers/*
/lambdas/*
/src/handlers/*
/src/lambdas/*

Work left for a v2 plugin to read the sst lambda setup and explicitly load the lambda handlers as entry points

Copy link
Member

@webpro webpro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Bryan! Happy to merge the SST plugin, but I do have a few remarks.

const entry = [
"sst.config.{js,cjs,mjs,ts}",
"{handlers,lambdas}/*.{js,cjs,mjs,ts}",
"src/{handlers,lambdas}/*.{js,cjs,mjs,ts}",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any docs/resources that indicate these could be considered defaults locations?

import type { IsPluginEnabled, Plugin } from "../../types/config.js";
import { hasDependency } from "../../util/plugin.js";

// link to sst docs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a relevant link to SST docs re. config.

// console.log('issues', issues);

assert.partialDeepStrictEqual(issues, {
unlisted: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea that most plugins follow is to have zero issues left, so we only need to check all issue counters are zero, e.g.:

assert.deepEqual(counters, {
  ...baseCounters,
    processed: 4,
    total: 4,
})

In case there are still issues left we bump the relevant counter and use additional separate assertions for issues like so:

assert(issues.devDependencies['package.json']['some-unused-dep']);

const cwdEmptyConfig = resolve('fixtures/plugins/sst/empty-config');
const cwdOneHandler = resolve('fixtures/plugins/sst/one-handler');
const cwdOneHandlerInSrcLambdas = resolve('fixtures/plugins/sst/one-handler-in-lambdas');
const cwdOneHandlerInSrcHandlers = resolve('fixtures/plugins/sst/one-handler-in-src');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe good to move each cwd to each test context individually to hold them together.

@@ -0,0 +1,4 @@
export type PluginConfig = {
plugins?: string[];
entryPathsOrPatterns?: string[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably coming from the template, any chance it could reflect the actual SST config interface? If there's nothing interesting from the plugin perspective it could be left empty or even removed.

});

// console.log('issues', issues);
// console.log('counters', counters);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove console.log statements

@webpro webpro force-pushed the main branch 2 times, most recently from e8120d3 to 93c724a Compare March 13, 2025 15:07
@webpro
Copy link
Member

webpro commented Mar 24, 2025

@BryanCrotazGivEnergy I've been working on support for a new resolveFromAST in plugins so we can implement functionality like in this PR. I'm going to update things better to clarify what's going on, but at least you know I'm working on this. Feel free to check it out, hack on it, provide feedback: #1005. There's also the pkg.pr.new publish so you could try it out.

@BryanCrotazGivEnergy
Copy link
Author

Sounds good, I'll take a look at #1005

@webpro
Copy link
Member

webpro commented Mar 31, 2025

Thank you. Your opinion will be valuable. Obviously you should be credited for your work, as I've copied lots of code and ideas from this PR. Maybe once #1005 is merged you'd be willing to improve the SST (or other) plugin with another PR, or even PR against #1005 directly.

@BryanCrotazGivEnergy
Copy link
Author

slogging through other pnpm issues, once those are sorted and we can build and deploy I'll return to this plugin and 1005

@webpro
Copy link
Member

webpro commented Apr 8, 2025

Closing this in favor of #1005.

@webpro webpro closed this Apr 8, 2025
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

Successfully merging this pull request may close these issues.

2 participants