diff --git a/scripts/prepublish.mjs b/scripts/prepublish.mjs index 292c0ebd3..a2afb4da1 100644 --- a/scripts/prepublish.mjs +++ b/scripts/prepublish.mjs @@ -93,13 +93,17 @@ const downloadMicrobitHex = async () => { const absoluteGeneratedDir = path.join(basePath, relativeGeneratedDir); fs.mkdirSync(absoluteGeneratedDir, {recursive: true}); const absoluteGeneratedFile = path.join(basePath, relativeGeneratedFile); + const requirePath = `./${path + .relative(relativeGeneratedDir, relativeHexFile) + .split(path.win32.sep) + .join(path.posix.sep)}`; fs.writeFileSync( absoluteGeneratedFile, [ '// This file is generated by scripts/prepublish.mjs', '// Do not edit this file directly', '// This file relies on a loader to turn this `require` into a URL', - `module.exports = require('./${path.relative(relativeGeneratedDir, relativeHexFile)}');`, + `module.exports = require('${requirePath}');`, '' // final newline ].join('\n') );