** bikeshed **
fs.getFile(url)
- https://developer.mozilla.org/en-US/docs/Web/API/File
Can be used by loaders/servers if they wish to request information about the file's MIME as file.type
.
It will get the .type
by checking the context for the current MIME DB, falling back to the globally MIME DB.
There are a few builtin DBs that are preconfigured for purposes. These are the relevant file extensions to each.
Extension | "cjs" (default) | "esm" | "web" |
---|---|---|---|
.js |
application/node |
text/javascript; goal=module |
text/javascript |
.mjs |
text/javascript; goal=module |
text/javascript; goal=module |
text/javascript; goal=module |
.node |
application/vnd.node.addon |
application/vnd.node.addon |
application/vnd.node.addon |
.json |
application/vnd.node.json |
application/json |
application/json |
Represented by either the value null
or the string "null"
.
It is a void, it always resolves to ""
instead of a MIME for any URL.
{
"mimes": "esm"
}
Put one in each directory as desired.
This MIME DB is only used inside of package boundaries.
It accepts either an array or string.
As an array it will go down the list until a DB returns a value. The null DB will prevent accessing the global DB.
{
"mimes": [null, "esm"]
}
Would effectively prevent any MIMEs from resolving inside of the package boundaries because the null
DB would be used and always return a value of ""
and prevent the resolution from reaching "esm"
.
URLs may be used and loaded instead of just preset values.
node --mimes="/path/to/react/jsx-mime.db" app.jsx
Use the null
DB if you need to compeltely exclude the builtin DB.
cat http-server | node --entry-mime="text/javascript"
DBs should be able to be provided by users and was always intended in this gist, a custom DB such as the following:
Extension | "custom" |
---|---|
.js |
text/javascript |
.cjs |
application/node |
.mjs |
text/javascript; goal=module |
Should be able to be loaded via w/e mechanisms load DBs.