Skip to content
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

feat: add integrity flag support #2571

Merged
merged 7 commits into from
Jul 14, 2024
Merged

feat: add integrity flag support #2571

merged 7 commits into from
Jul 14, 2024

Conversation

guybedford
Copy link
Member

Updates to the latest generator.

@JayaKrishnaNamburu
Copy link
Member

@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 ?

And btw, the import for @babel/core also seems to fail with import-map now.
https://jspm.org/sandbox#H4sIAAAAAAAAA6VZbXPTOBD+zq8Q4QvcVLaTttAraSfAdJiDhruhlLv7qNhyrFa2jCQnpDf891vJL4mN49jlQ14s7T7PanclreTp00D4epNSFOmYXz6Zlj+UBJdPEJrGVBPkR0Qqqi9GmQ7x2ch2aKY5vWRxKqSOSYrvVBrjmGgqGeE4Y1M3l6h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Jk5RAPXJwnLFMWwkdLc+VmSEv/eDAumV2fNs6sLuQMR9Dxv/PLEawVqEkeE33eBm34YCvik1SG+4MLU0MmqO3w1ObDyd+e4A+9AMbsVAqTxXiTLhfMZZNK4E7EpbMPntSIHdJF1zS7bD1lkFkgl/T3HV8rhICrNoUNgP5IiZlnsmn0BtvSucLfp2SXjbHxW6Te5lE9SWhZLki6hWOuiaBG3mXXa6o+wc3c6OCHCprWQp2qTdK2ehYS1ycMLqsme9FxysSC8y75CYjaGTJrsCfidAmff086wVDIQ+H2Jc6fAs50Y0A9uOoXR2P8NfS4z7BM/6poblczsFKZG+yrWeZiB88rEbrRtmiZ4kBCcEjDPza8NpDBnDhq4cJg1oewsZWsAeUac7MU5TF48YQUDNqeunxoeb08/6IaJKdHRL00GA9DEZL6wK15X1LZCdlKM3W2D077+FP7+NWtzDAy/QWZvFBokisarzv0yF5i9dMyOmz80IbLUHt+xHU0XVE0Q0v8UpmH72GHpDInSxm446mjWWcD8LNyxN2wIP1BqFBK2mh27xVN1d43Qjyflt/lM3fw23VyeFy8A0NUNmts7BnQTsVidl9f/sGsplAq+CRnnKBQSCR5QicriBq2ZjkSmEduRL7yGntMluiEhkQyNIRovitv88jKfmPUWwW52sX/TKG8+lLHK7MxeebPa6DOjRb4USgnJliy5gFJSJJtYZGp02Rxx7W1CjmJfJaByGL+BcegdZCkKYTesv0l4nYMg5LrobwkFEgyaJSiHQaakRhGV9AiBswCFIEVTc3sBWAwEjMOgcQTjHiGiYT9cZNAnEqQjWqLkBjqWBuoIOJhQh4vlc2PSi9e1GE7d/E3O1M3fOf0Pp+3wYIsaAAA=

@JayaKrishnaNamburu JayaKrishnaNamburu self-assigned this Jul 8, 2024
@guybedford
Copy link
Member Author

@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.

@JayaKrishnaNamburu
Copy link
Member

@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.

@guybedford
Copy link
Member Author

Yes, let's update the generator to use named exports now then?

@JayaKrishnaNamburu
Copy link
Member

cool, will update the PR here and make on on the generator for the same 👍

@guybedford
Copy link
Member Author

Let me know if I can help further on this PR at all.

@JayaKrishnaNamburu JayaKrishnaNamburu changed the title update: latest generator feat: add integrity flag support Jul 11, 2024
@guybedford guybedford merged commit 2e373b2 into main Jul 14, 2024
5 checks passed
@guybedford guybedford deleted the jspm-update branch July 14, 2024 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants