feat: all cjs export (#3189)

* feat: all cjs export

* test: fix deno test

* style: fix error  Expected space or tab before '*/' in comment  spaced-comment

* fix: deno import map

* fix: sneak in a fix for yarn
This commit is contained in:
Jonathan Ho
2023-11-26 17:17:54 -08:00
committed by GitHub
parent 887596125e
commit 1974834b20
24 changed files with 1020 additions and 53 deletions

View File

@@ -0,0 +1,16 @@
import fs from 'node:fs'
const dirs = ['']
for await (const dir of dirs) {
await Promise.all(
fs.readdirSync(`dist/cjs${dir}`).map(async (file) => {
if (!file.endsWith('.js') && !file.endsWith('.map') && !file.endsWith('.ts') && !file.endsWith('.cjs')) {
dirs.push(`${dir}/${file}`)
return
}
const content = await fs.promises.readFile(`dist/cjs${dir}/${file}`, 'utf-8')
await fs.promises.rm(`dist/cjs${dir}/${file}`)
fs.promises.writeFile(`dist/cjs${dir}/${file.slice(0, -3)}.cjs`, content.replace(/\.js/g, '.cjs'))
}),
)
}

View File

@@ -13,7 +13,7 @@ for await (const dir of dirs) {
fs.promises.writeFile(
`denoTestsDist${dir}/${file.slice(-8) === '.spec.js' ? `${file.slice(0, -7)}test.js` : file}`,
content
.replace(/src\//g, 'dist/')
.replace(/src\//g, 'dist/esm/')
.replace(/\.ts/g, '.js')
.replace(/describe\.skip/g, 'describe.ignore')
.replace(/it\.skip/g, 'it.ignore'),