-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
/~/
alias + build => Module not found on runtime
#290
Comments
@deckchairlabs, @mashaal, do we have working example with alias? Should have one |
Entries for paths with aliases just not created in Expected something like "/~/": "/src/",
"./src/app.tsx": "/src/app/app.fe83edc4.js",
"/~/app/app.tsx": "/src/app/app.fe83edc4.js", But no entries for |
Ultra uses mesozoic builder. Aliases should be added to mesozoic test fixture |
Wrote script which copies source code to subfolder and transforms absolute local imports with aliases to relative import there: d9k/citations-supabase-demo: script/copy-and-transform-imports-to-relative.ts const walkIterator = fs.walk(
PROJECT_COPY_WITH_IMPORTS_TRANSFORMED_TO_RELATIVE_PATH,
{
match: matchScriptsRegexArray,
},
);
for await (const scriptFileEntry of walkIterator) {
const scriptAbsPath = scriptFileEntry.path;
const scriptRelPath = path.relative(
PROJECT_COPY_WITH_IMPORTS_TRANSFORMED_TO_RELATIVE_PATH,
scriptAbsPath,
);
const scriptDirPath = path.dirname(scriptAbsPath);
console.debug('walk scripts:', scriptRelPath, scriptFileEntry.path);
const codeLines = Deno.readTextFileSync(scriptFileEntry.path);
const replaceQuotedPath: ReplaceCallback = (
_quotedPath,
importPathWithAlias,
) => {
console.debug(' ', importPathWithAlias);
const importPathAbs = importPathWithAlias.replace(/^\/~\//, () => {
return aliasSrcAbsPath + '/';
});
const importPathRelativeToScript = path.relative(
scriptDirPath,
importPathAbs,
);
const importPathRelativeToScriptStartsWithDot =
importPathRelativeToScript.match(/^\.\./)
? importPathRelativeToScript
: `./${importPathRelativeToScript}`;
return `'${importPathRelativeToScriptStartsWithDot}'`;
};
const transformStringWithQuotedPath = (stringWithQuotedPath: string) => {
const transformedString = stringWithQuotedPath.replace(
/'(.*)'/,
replaceQuotedPath,
);
console.debug('->', transformedString);
return transformedString;
};
const codeLinesWithRelImports = codeLines.replace(
/from[\s\n\r]+'\/~\/.*'/gm,
(fromWithQuotedPath) => {
console.debug(' ', fromWithQuotedPath);
return transformStringWithQuotedPath(fromWithQuotedPath);
},
/** async import */
).replace(/import\([\s\n\r]*'\/~\/.*'/gm, (fromWithQuotedPath) => {
console.debug(' ', fromWithQuotedPath);
return transformStringWithQuotedPath(fromWithQuotedPath);
});
Deno.writeTextFileSync(scriptAbsPath, codeLinesWithRelImports);
} |
https://github.com/d9k/citations-supabase-demo/tree/726f3da7cf16698975bc4906a8274967c03f705b
Error highlight
The text was updated successfully, but these errors were encountered: