invertase / dart_edge

Run Dart on the Edge - supporting Vercel & Cloudflare Workers (more coming soon).
https://docs.dartedge.dev
Apache License 2.0
324 stars 23 forks source link

`edge build supabase_functions` doesn't compile anything. #24

Closed gaetschwartz closed 1 year ago

gaetschwartz commented 1 year ago

https://github.com/invertase/dart_edge/blob/822785493f5fad3f876104a17bf5ff431bd02874/packages/edge/lib/src/commands/build_commands/build_supabase.dart#L58

The runBuild method is empty. I'm not sure but shouldn't it be something like

 Future<void> runBuild() async {
    final functionDirectory = Directory(
      p.join(Directory.current.path, 'supabase', 'functions', 'dart_edge'),
    );

    final compiler = Compiler(
      logger: logger,
      entryPoint: p.join(Directory.current.path, 'lib', 'main.dart'),
      outputDirectory: functionDirectory.path,
      outputFileName: 'main.dart.js',
      level: CompilerLevel.O1,
    );

    await compiler.compile();
}
Ehesp commented 1 year ago

Oh, woops!

Yes it should be:

  Future<void> runBuild() async {
    final functionDirectory = Directory(
      p.join(Directory.current.path, 'supabase', 'functions', 'dart_edge'),
    );

    final entryFile = File(p.join(functionDirectory.path, 'index.ts'));

    final compiler = Compiler(
      logger: logger,
      entryPoint: p.join(Directory.current.path, 'lib', 'main.dart'),
      outputDirectory: functionDirectory.path,
      outputFileName: 'main.dart.js',
      level: CompilerLevel.O4,
    );

    await compiler.compile();

    await entryFile.writeAsString(
      edgeFunctionEntryFileDefaultValue('main.dart.js'),
    );
  }

Feel free to PR - or I'll get around to it soon.

Ehesp commented 1 year ago

Also the dev build will still work for now in prod, it's just less optimised.

gaetschwartz commented 1 year ago

Feel free to PR - or I'll get around to it soon.

Working on a PR along a few other improvements :)

Ehesp commented 1 year ago

Quickly fixed this in a standalone PR: https://github.com/invertase/dart_edge/commit/c9c0fe3b3cd3496ce3fa3b7dab7f7d4a787d963e

solid-danylokhvan commented 1 year ago
Because every version of supabase_functions from git depends on edge from hosted and supabase_edge_functions depends on edge from git, supabase_functions from git is forbidden.
So, because supabase_edge_functions depends on supabase_functions from git, version solving failed.

When I'm trying to get supabase_functions 0.0.2+2 to fix building the supabase functions.