Skip to content

Commit

Permalink
ci: fix race condition writing globals.d.ts shim
Browse files Browse the repository at this point in the history
  • Loading branch information
ascorbic authored and MichaelDeBoey committed Nov 30, 2022
1 parent b09020a commit d754670
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion scripts/build.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { spawn } from "cross-spawn";

const args = process.argv.slice(2);
const tsc = process.env.CI || args.includes("--tsc");
const publish = process.env.CI || args.includes("--publish");
const tsc = process.env.CI || args.includes("--tsc") || publish;

exec("yarn", ["rollup", "-c"])
.then(() => tsc && exec("yarn", ["tsc", "-b"]))
Expand Down
28 changes: 12 additions & 16 deletions scripts/copy-build-to-dist.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ async function copyBuildToDist() {
};
});

// Write an export shim for @remix-run/node/globals types
let dest = path.join(
".",
"build",
"node_modules",
"@remix-run",
"node",
"globals.d.ts"
);
console.log(chalk.yellow(` 🛠 Writing globals.d.ts shim to ${dest}`));
await fse.writeFile(dest, "export * from './dist/globals';");

/** @type {Promise<void>[]} */
let copyQueue = [];
for (let pkg of packages) {
Expand Down Expand Up @@ -65,22 +77,6 @@ async function copyBuildToDist() {
} catch (e) {}
}

// Write an export shim for @remix-run/node/globals types
copyQueue.push(
(async () => {
let dest = path.join(
".",
"build",
"node_modules",
"@remix-run",
"node",
"globals.d.ts"
);
console.log(chalk.yellow(` 🛠 Writing globals.d.ts shim to ${dest}`));
await fse.writeFile(dest, "export * from './dist/globals';");
})()
);

// One-off deep import copies so folks don't need to import from inside of
// dist/. TODO: Remove in v2 and either get rid of the deep import or manage
// with the package.json "exports" field
Expand Down

0 comments on commit d754670

Please sign in to comment.