framework icon indicating copy to clipboard operation
framework copied to clipboard

custom builtins

Open mbostock opened this issue 1 year ago • 2 comments

Sketch at #928. The main thing missing is the equivalent of getImplicitInputImports, getImplicitDownloads, etc. Also, I’d rather have this live inside the config file, but I think it’s harder to express the builtins as code if we do that?

mbostock avatar Mar 16 '24 17:03 mbostock

Without trying to implement it (so I'm probably missing why it's difficult), I imagined you could say this in a config file:

const confetti = () => import("npm:canvas-confetti").then((confetti) => confetti.default);

export default {
  builtins: {confetti},
  ...
}

Or, adding imports and downloads as keys:

const confetti = {
  module: () => import("npm:canvas-confetti").then((confetti) => confetti.default),
  imports: … ,
  downloads: …
};

export default {
  builtins: {confetti},
  ...
}

Fil avatar Mar 18 '24 13:03 Fil

Try it in our config and you’ll see why. The config is server-side code, so we don’t want to use it to define client-side code.

mbostock avatar Mar 18 '24 14:03 mbostock