vrml1to97/tools/modulize.mjs
Glen Whitney e0861ea157 feat: install moo and use in toy example (#2)
I failed to find a satisfactory way to compile and import moo.js with
  fixed specifiers, so finally I just gave up and patched the distributed
  moo code to be an es6 module. Very ugly but it works.

Resolves #1.

Reviewed-on: #2
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Co-committed-by: Glen Whitney <glen@studioinfinity.org>
2023-09-01 21:32:25 +00:00

10 lines
363 B
JavaScript

import {stdin, argv} from 'node:process'
import {streamToString} from '../etc/streamToString.js'
const preamble = `// ES6 Module converted from https://github.com/no-context/moo
export default (((f) => f())(function () {
`
const umd = await streamToString(stdin)
const realStart = umd.indexOf(" 'use strict'")
console.log(preamble + umd.substring(realStart))