Skip to content

Commit

Permalink
Merge pull request #2934 from preactjs/compat-entry
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister committed Jan 17, 2021
2 parents 4a54b86 + dbe95b6 commit 19549d8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
25 changes: 25 additions & 0 deletions config/compat-entries.js
@@ -0,0 +1,25 @@
const path = require('path');
const fs = require('fs');
const kl = require('kolorist');

const pkgFiles = new Set(require('../package.json').files);
const compatDir = path.join(__dirname, '..', 'compat');
const files = fs.readdirSync(compatDir);

let missing = 0;
for (const file of files) {
const expected = 'compat/' + file;
if (/\.(js|mjs)$/.test(file) && !pkgFiles.has(expected)) {
missing++;

const filePath = kl.cyan('compat/' + file);
const label = kl.inverse(kl.red(' ERROR '));
console.error(
`${label} File ${filePath} is missing in "files" entry in package.json`
);
}
}

if (missing > 0) {
process.exit(1);
}
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -81,7 +81,7 @@
"build:test-utils": "microbundle build --raw --cwd test-utils",
"build:compat": "microbundle build --raw --cwd compat --globals 'preact/hooks=preactHooks'",
"build:jsx": "microbundle build --raw --cwd jsx-runtime",
"postbuild": "node ./config/node-13-exports.js",
"postbuild": "node ./config/node-13-exports.js && node ./config/compat-entries.js",
"dev": "microbundle watch --raw --format cjs",
"dev:hooks": "microbundle watch --raw --format cjs --cwd hooks",
"dev:compat": "microbundle watch --raw --format cjs --cwd compat --globals 'preact/hooks=preactHooks'",
Expand Down Expand Up @@ -169,6 +169,7 @@
"compat/dist",
"compat/src",
"compat/server.js",
"compat/test-utils.js",
"compat/jsx-runtime.js",
"compat/jsx-runtime.mjs",
"compat/jsx-dev-runtime.js",
Expand Down

0 comments on commit 19549d8

Please sign in to comment.