Skip to content

Commit

Permalink
fix: enable support for esm data files
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed May 7, 2021
1 parent f29ccb3 commit 25b3336
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions plugins/cc-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"@component-controls/webpack-compile": "^3.9.1",
"@component-controls/webpack-configs": "^3.9.0",
"dot": "^1.1.3",
"esm": "^3.2.25",
"path": "^0.12.7"
},
"devDependencies": {
Expand Down
9 changes: 8 additions & 1 deletion plugins/cc-cli/src/cli/save-data-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ export const saveDataTemplate = async <P extends TemplateOptions>(
if (fs.existsSync(filePath)) {
if (overwrite) {
//load existing data file
existing = require(filePath);

existing = require('esm')(module)(filePath);
if (
!existing ||
(typeof existing === 'object' && Object.keys(existing).length === 0)
) {
existing = require(filePath);
}
} else {
return undefined;
}
Expand Down

0 comments on commit 25b3336

Please sign in to comment.