Skip to content

Commit

Permalink
fix: add pkg with sideEffects for esm build
Browse files Browse the repository at this point in the history
  • Loading branch information
yarastqt committed Aug 28, 2020
1 parent acf146f commit a86c32b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/pack/src/plugins/TypeScriptPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,18 @@ class TypeScriptPlugin implements Plugin {
}

private async generateModulePackage(src: string): Promise<void> {
const files = await glob('**/index.js', { cwd: src, ignore: ['esm/**/index.js'] })
const files = await glob('**/index.js', { cwd: src })
for (const file of files) {
const moduleDirname = dirname(file)
const esmModuleDirname = dirname(join('esm', file))
const packageJsonPath = resolve(src, moduleDirname, 'package.json')
const json: { sideEffects: string[]; module?: string } = { sideEffects: ['.css'] }

await writeJson(packageJsonPath, {
module: join(relative(moduleDirname, esmModuleDirname), 'index.js'),
sideEffects: ['.css'],
})
if (file.match(/^esm/) === null) {
json.module = join(relative(moduleDirname, esmModuleDirname), 'index.js')
}

await writeJson(packageJsonPath, json)
}
}
}
Expand Down

0 comments on commit a86c32b

Please sign in to comment.