Open NullVoxPopuli opened 4 months ago
I made a lightweight CLI^1 with performance in mind that integrating meta data of nolyfill as one of presets.
Basically it streaming lockfile line-by-line by doing plain filtering on package names and nothing more. Still in earlier stage, feedback is welcome.
Basically it streaming lockfile line-by-line
Stream parsing is almost impossible for YAML format (which is the format of pnpm-lock.yaml
).
Yes, support all kinds of lockfiles would be an epic effort, thus I'd shortcut by calling npm shrinkwrap
and use npm-shrinkwrap.json
as single source of truth, at least for now.
const headers = { 'Content-Type': 'text/html' };
const html = `
<!doctype html>
<head>
<script type="importmap">
{
"imports": {
"pkg-fence/": "https://esm.sh/jsr/@imcotton/pkg-fence@0.6.0/"
}
}
</script>
<script type="module">
import { nolyfill } from 'pkg-fence/presets';
console.log(nolyfill.list.length);
console.log(nolyfill.list.slice(0, 5));
console.log(nolyfill.check('hasown'));
</script>
</head>
<body>
<p>hello, JSR via esm.sh</p>
</body>
`;
export default {
fetch () {
return new Response(html, { headers });
},
};
For sake of demonstration, save above code snippet as demo.js
and try:
deno serve demo.js
I can't use the CLI, because even with 32G of max-old-space-size, I get the OOM error, reported here: https://github.com/SukkaW/nolyfill/issues/33
We don't need a CLI -- we can copy-paste a list of overrides -- any packages we don't actually use would no-op.