Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Check if both CJS and ESM builds succeeded #876

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions/prepare-playground
- run: npx nx affected --target=build --parallel=3 --verbose
# Make sure that both the ESM and CJS builds of the affected
# modules still produce usable bundles
- run: npx nx affected --target=test:esmcjs --parallel=3 --verbose

# Deploy documentation job
deploy_docs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@ export default async function runExecutor(
const testsPath = path.join(context.root, buildDir, 'test-esm-cjs');
mkdirSync(testsPath, { recursive: true });

const testESMPath = path.join(testsPath, 'test-esm.mjs');
writeFileSync(
path.join(testsPath, 'test-esm.mjs'),
testESMPath,
`import * as result from '../../${options.outputPath}/index.js';`
);
writeFileSync(
path.join(testsPath, 'test-cjs.cjs'),
`require('../../${options.outputPath}');`
);
const checkForSuccess = (scriptName) =>
const testCJSPath = path.join(testsPath, 'test-cjs.cjs');
writeFileSync(testCJSPath, `require('../../${options.outputPath}');`);
const checkForSuccess = (scriptPath) =>
new Promise((resolve, reject) => {
const test = spawn('sh', ['node', scriptName], {
const test = spawn('node', [scriptPath], {
cwd: testsPath,
stdio: 'pipe',
});
Expand All @@ -49,7 +48,7 @@ export default async function runExecutor(
});
});

await checkForSuccess('test-esm.mjs');
await checkForSuccess('test-cjs.cjs');
await checkForSuccess(testESMPath);
await checkForSuccess(testCJSPath);
return { success: true };
}
7 changes: 0 additions & 7 deletions packages/playground/wordpress/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@
"executor": "nx:noop",
"dependsOn": ["test:vite"]
},
"test:esmcjs": {
"executor": "@wp-playground/nx-extensions:assert-built-esm-and-cjs",
"options": {
"outputPath": "dist/packages/playground/wordpress"
},
"dependsOn": ["build"]
},
"test:vite": {
"executor": "@nx/vite:test",
"outputs": [
Expand Down
Loading