8e79f1cb27
* improve Tree Shaking in ESM Instead of bundling everything into a single ESM file, we generate every single file as ESM. This is what we did in 1.4.x as well. I would expect if your library had a single ESM file and you only used 1 function that the application you use it in correctly does the tree-shakign for you. Apparantly a lot of applications are not properly setup for this, so let's create multiple files instead. * update changelog
17 lines
498 B
JavaScript
Executable File
17 lines
498 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
let fs = require('fs')
|
|
let path = require('path')
|
|
let fastGlob = require('fast-glob')
|
|
|
|
console.time('Rewrote imports in')
|
|
fastGlob.sync([process.argv.slice(2).join('')]).forEach((file) => {
|
|
file = path.resolve(process.cwd(), file)
|
|
let content = fs.readFileSync(file, 'utf8')
|
|
let result = content.replace(/from([^"']*?)(["'])\.(.*?)\2/g, 'from$1".$3.js"')
|
|
if (result !== content) {
|
|
fs.writeFileSync(file, result, 'utf8')
|
|
}
|
|
})
|
|
console.timeEnd('Rewrote imports in')
|