Skip to content
Closed
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
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,29 @@ jobs:
- run: pnpm install --no-lockfile
- run: pnpm --filter "@embroider/*" test

legacy-macros:
runs-on: ubuntu-latest
timeout-minutes: 5

strategy:
fail-fast: false
matrix:
node: ["12.22.12", "14.21.3", "16.20.2", "18.20.8", "20.19.5", "22.20.0", "24.9.0"]

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22 # this is only used for the pnpm install, the user-node-version above will be used in tests
cache: pnpm
- run: pnpm install --no-lockfile
- name: downgrade Node Version in .npmrc
run: printf "auto-install-peers=false\nuse-node-version=${{matrix.node}}" > .npmrc
- run: pnpm node -v
- run: cat .npmrc
- run: pnpm --filter "@embroider/macros" test:smoke

preflight:
runs-on: ubuntu-latest
timeout-minutes: 5
Expand Down
3 changes: 2 additions & 1 deletion packages/macros/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"src/**/*.js.map"
],
"scripts": {
"test": "vitest"
"test": "vitest",
"test:smoke": "node smoke-test.js"
},
"dependencies": {
"@embroider/shared-internals": "workspace:*",
Expand Down
34 changes: 34 additions & 0 deletions packages/macros/smoke-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
console.log(process.version);

var babel = require("@babel/core");

const { join } = require('path');

const { MacrosConfig } = require('./src/node');

let config = MacrosConfig.for({}, __dirname);

let response = babel.transform(`
import { macroCondition } from '@embroider/macros';
export default function() {
if (macroCondition(true)) {
return 'alpha';
} else {
return 'beta';
}
}
`, {
filename: join(__dirname, 'sample.js'),
configFile: false,
plugins: config.babelPluginConfig(),
});


if(response.code.trim() !== `export default function () {
{
return 'alpha';
}
}`.trim()) {
console.error(response.code);
throw new Error("smoke test failed");
}
14 changes: 8 additions & 6 deletions packages/macros/tests/babel/import-sync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,19 @@ describe('importSync', function () {
import * as _importSync20 from "../../README";
import * as _importSync40 from "../../node_modules";
import * as _importSync60 from "../../package";
import * as _importSync80 from "../../src";
import * as _importSync00 from "../../tests";
import * as _importSync100 from "../../vitest.config";
import * as _importSync80 from "../../smoke-test";
import * as _importSync00 from "../../src";
import * as _importSync100 from "../../tests";
import * as _importSync120 from "../../vitest.config";
function getFile(file) {
return {
"README": esc(_importSync20),
"node_modules": esc(_importSync40),
"package": esc(_importSync60),
"src": esc(_importSync80),
"tests": esc(_importSync00),
"vitest.config": esc(_importSync100)
"smoke-test": esc(_importSync80),
"src": esc(_importSync00),
"tests": esc(_importSync100),
"vitest.config": esc(_importSync120)
}[file].default;
}"
`);
Expand Down
Loading