jspm / generator

JSPM Import Map Generator
Apache License 2.0
165 stars 21 forks source link

Scope dependency is upgraded by major after install #165

Closed huntercaron closed 2 years ago

huntercaron commented 2 years ago

When installing connectkit using a newly created generator, one of the scope dependencies is bumped a major.

Screenshot 2022-08-11 at 15 33 30

This does not happen when using the same generator instance between installs, but due to our worker setup at Framer we are not able to share the same generator instance, which leads to this bug.

Repro using @jspm/generator beta.35: (This does not happen in beta.31)

import { Generator } from "@jspm/generator";

const RESOLUTIONS = {
  "@react-three/fiber": "7.0.27",
};

const PROVIDED_DEPENDENCIES = new Set([
  "react",
  "react/jsx-runtime",
  "react-dom",
  "react-dom/server",
  "framer",
  "framer-motion",
  "framer-motion/three",
]);

const BASE_CONFIG = {
  mapUrl: "about:blank",
  ignore: Array.from(PROVIDED_DEPENDENCIES),
  env: ["production", "browser", "module"],
  resolutions: RESOLUTIONS,
};

async function Repro() {
  const generatorOne = new Generator(BASE_CONFIG);

  await generatorOne.install("@react-three/fiber");
  console.log(generatorOne.getMap().scopes["https://ga.jspm.io/"].zustand);

  const generatorTwo = new Generator({
    ...BASE_CONFIG,
    inputMap: generatorOne.getMap(),
  });

  await generatorTwo.install("wagmi");
  console.log(generatorTwo.getMap().scopes["https://ga.jspm.io/"].zustand);

  const generatorThree = new Generator({
    ...BASE_CONFIG,
    inputMap: generatorTwo.getMap(),
  });

  await generatorThree.install("connectkit");
  console.log(generatorThree.getMap().scopes["https://ga.jspm.io/"].zustand);
}

Repro().catch((e) => console.error(e));
guybedford commented 2 years ago

I managed to track down the issue here, and it's an interesting edge case. Unfortunately won't get a fix together today, but we can definitely get one through by Monday / Tuesday next week.

huntercaron commented 2 years ago

amazing, thank you!

guybedford commented 2 years ago

Turned out to be a big and important reworking, thanks for sharing the case. Fix released in 1.0.0-beta.36.