Closed guybedford closed 2 months ago
@guybedford i started looking into this, and the tests are failing from the usage of @babel/core
. We get @babel/core@7.24
now from the @jspm/generator
. So during the check for type of file. The tests are failing now.
Which is here
const source = await fs.readFile(resolvedModule.target, { encoding: "utf8" });
const babel = await import("@babel/core");
try {
babel.parse(source);
return resolvedModule; // this is a javascript module, it parsed correctly
} catch (e) {
/* fallback to parsing it as html */
}
https://github.com/jspm/jspm-cli/blob/main/src/link.ts#L130
But seems there is no default
exports in node env.
https://codesandbox.io/p/devbox/elated-saha-qw6s77?file=%2Fpackage.json%3A11%2C49
It passes if its changed to named-import here. But then the tracer from @jspm/generator
again uses the same approach and the tests fail.
export async function createCjsAnalysis(
imports: any,
source: string,
url: string
): Promise<Analysis> {
if (!babel) ({ default: babel } = await import("@babel/core"));
const requires = new Set<string>();
const lazy = new Set<string>();
const unboundGlobals = new Set<string>();
babel.transform(source, {
ast: false,
sourceMaps: false,
https://github.com/jspm/generator/blob/main/src/trace/cjs.ts#L24
The one from the generators seems to pass because the project is built using rollup there. And i suspect the behaviour in both the places is little different. Should we switch to named-imports in both the places. Any inputs fro this ?
@JayaKrishnaNamburu thanks for looking into this. I've pushed a fix for Babel, is it working now for you? You may need to clear your browser cache.
@guybedford the fix for jspm is working good now. Should we switch to namedImports
for @babel/core
in generator and in the cli. Because the direct import of @babel/core
is missing the default
export from the package in node env.
Yes, let's update the generator to use named exports now then?
cool, will update the PR here and make on on the generator for the same 👍
Let me know if I can help further on this PR at all.
Updates to the latest generator.