If you want to require a file attachment, it’s:
foo = require(await FileAttachment("foo.js").url())
This assumes that your file (foo.js) is compatible with AMD (d3-require). If you want to load a standard ES module instead, you can use dynamic import:
foo = import(await FileAttachment("foo.js").url())