Can't get capacitor.js to work

I want to use Capacitor with my plain old Javascript webapp. I am not using modules, or nodejs or any of the bazillion of buildsystems etc. Just plain vanilla Javascript files. I understand I have to set

“bundledWebRuntime”: true

in the capacitor.json.config and then include capacitor.js in my HTML file like so

<script src="capacitor.js"></script>

But how do I actually use the various APIs now? The examples only use this weird import syntax, that I am unfamiliar with and that I don’t need. I assumed everything would now simply be available under a global “Capacitor” object but that is not so.

Take this simple example from the API docs:

 import { Plugins, FilesystemDirectory, FilesystemEncoding } from '@capacitor/core'; 
 const { Filesystem } = Plugins;
 
 async fileWrite() {
     const result = await Filesystem.writeFile({
       path: 'secrets/text.txt',
       data: "This is a test",
       directory: FilesystemDirectory.Documents,
       encoding: FilesystemEncoding.UTF8
     })
     console.log('Wrote file', result);
 }

How do I call it with capacitor.js? I figured It would be

 async fileWrite() {
     const result = await Capacitor.Plugins.Filesystem.writeFile({
       path: 'secrets/text.txt',
       data: "This is a test",
       directory: Capacitor.FilesystemDirectory.Documents,
       encoding: Capacitor.FilesystemEncoding.UTF8
     })
     console.log('Wrote file', result);
 }

But I keep getting reference errors for Capacitor.FilesystemDirectory.Documents, I also tried with Capacitor.Plugins.FilesystemDirectory.Documents or plain FilesystemDirectory.Documents, none of which work.

Help please!

I am having the exact same issue. Did you ever figure it out?