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

htmlInject might generate a wrong result #390

Open
oshmkufa2010 opened this issue Nov 21, 2024 · 1 comment
Open

htmlInject might generate a wrong result #390

oshmkufa2010 opened this issue Nov 21, 2024 · 1 comment

Comments

@oshmkufa2010
Copy link

  • jspm generator version: 2.4.1
  • input:
import { Generator } from '@jspm/generator';

const generator = new Generator({
  env: ['production', 'browser', 'module'],
});

(async function() {

console.log(await generator.htmlInject(`
  <!doctype html>
  <script type="module">
    import * as Material from "@mui/material";
    import * as react from "react";

    // Write main module code here, or as a separate file with a "src" attribute on the module script.
    console.log(Material, react);
  </script>
`, {
  trace: true,
  esModuleShims: true,
}));

})()
  • output:
  <!doctype html>
  <!-- Generated by @jspm/generator - https://github.com/jspm/generator -->
  <script async src="https://ga.jspm.io/npm:[email protected]/dist/es-module-shims.js" crossorigin="anonymous"></script>
  <script type="importmap">
  {
    "imports": {
      "@mui/material": "https://ga.jspm.io/npm:@mui/[email protected]/index.js",
      "react": "https://ga.jspm.io/npm:[email protected]/index.js"
    },
    "scopes": {
      "https://ga.jspm.io/": {
        "@babel/runtime/helpers/esm/assertThisInitialized": "https://ga.jspm.io/npm:@babel/[email protected]/helpers/esm/assertThisInitialized.js",
        "@babel/runtime/helpers/esm/extends": "https://ga.jspm.io/npm:@babel/[email protected]/helpers/esm/extends.js",
        "@babel/runtime/helpers/esm/inheritsLoose": "https://ga.jspm.io/npm:@babel/[email protected]/helpers/esm/inheritsLoose.js",
        "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose": "https://ga.jspm.io/npm:@babel/[email protected]/helpers/esm/objectWithoutPropertiesLoose.js",
        "@babel/runtime/helpers/extends": "https://ga.jspm.io/npm:@babel/[email protected]/helpers/esm/extends.js",
        "@emotion/cache": "https://ga.jspm.io/npm:@emotion/[email protected]/dist/emotion-cache.browser.esm.js",
        "@emotion/hash": "https://ga.jspm.io/npm:@emotion/[email protected]/dist/emotion-hash.esm.js",
        "@emotion/is-prop-valid": "https://ga.jspm.io/npm:@emotion/[email protected]/dist/emotion-is-prop-valid.esm.js",
        "@emotion/memoize": "https://ga.jspm.io/npm:@emotion/[email protected]/dist/emotion-memoize.esm.js",
        "@emotion/react": "https://ga.jspm.io/npm:@emotion/[email protected]/dist/emotion-react.browser.esm.js",
        "@emotion/serialize": "https://ga.jspm.io/npm:@emotion/[email protected]/dist/emotion-serialize.esm.js",
        "@emotion/sheet": "https://ga.jspm.io/npm:@emotion/[email protected]/dist/emotion-sheet.esm.js",
        "@emotion/styled": "https://ga.jspm.io/npm:@emotion/[email protected]/dist/emotion-styled.browser.esm.js",
        "@emotion/unitless": "https://ga.jspm.io/npm:@emotion/[email protected]/dist/emotion-unitless.esm.js",
        "@emotion/use-insertion-effect-with-fallbacks": "https://ga.jspm.io/npm:@emotion/[email protected]/dist/emotion-use-insertion-effect-with-fallbacks.browser.esm.js",
        "@emotion/utils": "https://ga.jspm.io/npm:@emotion/[email protected]/dist/emotion-utils.browser.esm.js",
        "@emotion/weak-memoize": "https://ga.jspm.io/npm:@emotion/[email protected]/dist/emotion-weak-memoize.esm.js",
        "@mui/private-theming": "https://ga.jspm.io/npm:@mui/[email protected]/index.js",
        "@mui/styled-engine": "https://ga.jspm.io/npm:@mui/[email protected]/index.js",
        "@mui/system": "https://ga.jspm.io/npm:@mui/[email protected]/esm/index.js",
        "@mui/system/DefaultPropsProvider": "https://ga.jspm.io/npm:@mui/[email protected]/esm/DefaultPropsProvider/index.js",
        "@mui/system/Grid": "https://ga.jspm.io/npm:@mui/[email protected]/esm/Grid/index.js",
        "@mui/system/InitColorSchemeScript": "https://ga.jspm.io/npm:@mui/[email protected]/esm/InitColorSchemeScript/index.js",
        "@mui/system/RtlProvider": "https://ga.jspm.io/npm:@mui/[email protected]/esm/RtlProvider/index.js",
        "@mui/system/colorManipulator": "https://ga.jspm.io/npm:@mui/[email protected]/esm/colorManipulator/index.js",
        "@mui/system/createBreakpoints": "https://ga.jspm.io/npm:@mui/[email protected]/esm/createBreakpoints/index.js",
        "@mui/system/createStyled": "https://ga.jspm.io/npm:@mui/[email protected]/esm/createStyled/index.js",
        "@mui/system/createTheme": "https://ga.jspm.io/npm:@mui/[email protected]/esm/createTheme/index.js",
        "@mui/system/cssVars": "https://ga.jspm.io/npm:@mui/[email protected]/esm/cssVars/index.js",
        "@mui/system/spacing": "https://ga.jspm.io/npm:@mui/[email protected]/esm/spacing/index.js",
        "@mui/system/style": "https://ga.jspm.io/npm:@mui/[email protected]/esm/style/index.js",
        "@mui/system/styleFunctionSx": "https://ga.jspm.io/npm:@mui/[email protected]/esm/styleFunctionSx/index.js",
        "@mui/system/useMediaQuery": "https://ga.jspm.io/npm:@mui/[email protected]/esm/useMediaQuery/index.js",
        "@mui/system/useThemeProps": "https://ga.jspm.io/npm:@mui/[email protected]/esm/useThemeProps/index.js",
        "@mui/utils": "https://ga.jspm.io/npm:@mui/[email protected]/esm/index.js",
        "@mui/utils/ClassNameGenerator": "https://ga.jspm.io/npm:@mui/[email protected]/esm/ClassNameGenerator/index.js",
        "@mui/utils/HTMLElementType": "https://ga.jspm.io/npm:@mui/[email protected]/esm/HTMLElementType/index.js",
        "@mui/utils/appendOwnerState": "https://ga.jspm.io/npm:@mui/[email protected]/esm/appendOwnerState/index.js",
        "@mui/utils/capitalize": "https://ga.jspm.io/npm:@mui/[email protected]/esm/capitalize/index.js",
        "@mui/utils/chainPropTypes": "https://ga.jspm.io/npm:@mui/[email protected]/esm/chainPropTypes/index.js",
        "@mui/utils/clamp": "https://ga.jspm.io/npm:@mui/[email protected]/esm/clamp/index.js",
        "@mui/utils/composeClasses": "https://ga.jspm.io/npm:@mui/[email protected]/esm/composeClasses/index.js",
        "@mui/utils/createChainedFunction": "https://ga.jspm.io/npm:@mui/[email protected]/esm/createChainedFunction/index.js",
        "@mui/utils/debounce": "https://ga.jspm.io/npm:@mui/[email protected]/esm/debounce/index.js",
        "@mui/utils/deepmerge": "https://ga.jspm.io/npm:@mui/[email protected]/esm/deepmerge/index.js",
        "@mui/utils/deprecatedPropType": "https://ga.jspm.io/npm:@mui/[email protected]/esm/deprecatedPropType/index.js",
        "@mui/utils/elementAcceptingRef": "https://ga.jspm.io/npm:@mui/[email protected]/esm/elementAcceptingRef/index.js",
        "@mui/utils/elementTypeAcceptingRef": "https://ga.jspm.io/npm:@mui/[email protected]/esm/elementTypeAcceptingRef/index.js",
        "@mui/utils/exactProp": "https://ga.jspm.io/npm:@mui/[email protected]/esm/exactProp/index.js",
        "@mui/utils/extractEventHandlers": "https://ga.jspm.io/npm:@mui/[email protected]/esm/extractEventHandlers/index.js",
        "@mui/utils/formatMuiErrorMessage": "https://ga.jspm.io/npm:@mui/[email protected]/esm/formatMuiErrorMessage/index.js",
        "@mui/utils/generateUtilityClass": "https://ga.jspm.io/npm:@mui/[email protected]/esm/generateUtilityClass/index.js",
        "@mui/utils/generateUtilityClasses": "https://ga.jspm.io/npm:@mui/[email protected]/esm/generateUtilityClasses/index.js",
        "@mui/utils/getDisplayName": "https://ga.jspm.io/npm:@mui/[email protected]/esm/getDisplayName/index.js",
        "@mui/utils/getReactElementRef": "https://ga.jspm.io/npm:@mui/[email protected]/esm/getReactElementRef/index.js",
        "@mui/utils/getScrollbarSize": "https://ga.jspm.io/npm:@mui/[email protected]/esm/getScrollbarSize/index.js",
        "@mui/utils/getValidReactChildren": "https://ga.jspm.io/npm:@mui/[email protected]/esm/getValidReactChildren/index.js",
        "@mui/utils/integerPropType": "https://ga.jspm.io/npm:@mui/[email protected]/esm/integerPropType/index.js",
        "@mui/utils/isFocusVisible": "https://ga.jspm.io/npm:@mui/[email protected]/esm/isFocusVisible/index.js",
        "@mui/utils/isMuiElement": "https://ga.jspm.io/npm:@mui/[email protected]/esm/isMuiElement/index.js",
        "@mui/utils/mergeSlotProps": "https://ga.jspm.io/npm:@mui/[email protected]/esm/mergeSlotProps/index.js",
        "@mui/utils/ownerDocument": "https://ga.jspm.io/npm:@mui/[email protected]/esm/ownerDocument/index.js",
        "@mui/utils/ownerWindow": "https://ga.jspm.io/npm:@mui/[email protected]/esm/ownerWindow/index.js",
        "@mui/utils/refType": "https://ga.jspm.io/npm:@mui/[email protected]/esm/refType/index.js",
        "@mui/utils/requirePropFactory": "https://ga.jspm.io/npm:@mui/[email protected]/esm/requirePropFactory/index.js",
        "@mui/utils/resolveComponentProps": "https://ga.jspm.io/npm:@mui/[email protected]/esm/resolveComponentProps/index.js",
        "@mui/utils/resolveProps": "https://ga.jspm.io/npm:@mui/[email protected]/esm/resolveProps/index.js",
        "@mui/utils/setRef": "https://ga.jspm.io/npm:@mui/[email protected]/esm/setRef/index.js",
        "@mui/utils/unsupportedProp": "https://ga.jspm.io/npm:@mui/[email protected]/esm/unsupportedProp/index.js",
        "@mui/utils/useControlled": "https://ga.jspm.io/npm:@mui/[email protected]/esm/useControlled/index.js",
        "@mui/utils/useEnhancedEffect": "https://ga.jspm.io/npm:@mui/[email protected]/esm/useEnhancedEffect/index.js",
        "@mui/utils/useEventCallback": "https://ga.jspm.io/npm:@mui/[email protected]/esm/useEventCallback/index.js",
        "@mui/utils/useForkRef": "https://ga.jspm.io/npm:@mui/[email protected]/esm/useForkRef/index.js",
        "@mui/utils/useId": "https://ga.jspm.io/npm:@mui/[email protected]/esm/useId/index.js",
        "@mui/utils/useLazyRef": "https://ga.jspm.io/npm:@mui/[email protected]/esm/useLazyRef/index.js",
        "@mui/utils/usePreviousProps": "https://ga.jspm.io/npm:@mui/[email protected]/esm/usePreviousProps/index.js",
        "@mui/utils/useSlotProps": "https://ga.jspm.io/npm:@mui/[email protected]/esm/useSlotProps/index.js",
        "@mui/utils/useTimeout": "https://ga.jspm.io/npm:@mui/[email protected]/esm/useTimeout/index.js",
        "@mui/utils/visuallyHidden": "https://ga.jspm.io/npm:@mui/[email protected]/esm/visuallyHidden/index.js",
        "@popperjs/core": "https://ga.jspm.io/npm:@popperjs/[email protected]/lib/index.js",
        "clsx": "https://ga.jspm.io/npm:[email protected]/dist/clsx.mjs",
        "dom-helpers/addClass": "https://ga.jspm.io/npm:[email protected]/esm/addClass.js",
        "dom-helpers/removeClass": "https://ga.jspm.io/npm:[email protected]/esm/removeClass.js",
        "hoist-non-react-statics": "https://ga.jspm.io/npm:[email protected]/dist/hoist-non-react-statics.cjs.js",
        "process": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/process-production.js",
        "prop-types": "https://ga.jspm.io/npm:[email protected]/index.js",
        "react": "https://ga.jspm.io/npm:[email protected]/index.js",
        "react-dom": "https://ga.jspm.io/npm:[email protected]/index.js",
        "react-is": "https://ga.jspm.io/npm:[email protected]/index.js",
        "react-transition-group": "https://ga.jspm.io/npm:[email protected]/esm/index.js",
        "react/jsx-runtime": "https://ga.jspm.io/npm:[email protected]/jsx-runtime.js",
        "scheduler": "https://ga.jspm.io/npm:[email protected]/index.js",
        "stylis": "https://ga.jspm.io/npm:[email protected]/index.js"
      },
      "https://ga.jspm.io/npm:[email protected]/": {
        "react-is": "https://ga.jspm.io/npm:[email protected]/index.js"
      },
      "https://ga.jspm.io/npm:[email protected]/": {
        "react-dom": "https://ga.jspm.io/npm:[email protected]/index.js"
      }
    }
  }
  </script>
  <script type="module">
    import * as Material from "@mui/material";
    import * as react from "react";

    // Write main module code here, or as a separate file with a "src" attribute on the module script.
    console.log(Material, react);
  </script>

notice "react": "https://ga.jspm.io/npm:[email protected]/index.js" which will cause an error: Uncaught TypeError: Cannot read properties of undefined (reading 'ReactCurrentOwner')

@guybedford
Copy link
Member

This seems to be working correctly now - see the sandbox example at https://jspm.org/sandbox#H4sIAAAAAAAAA7WaW1fbOhbH3/spdDIvM7Nqm9DL9NDQFQ6Eli7S4TTQrnlU7B0ssC2PJAdCV7/7bMk2xI6xbPfMA5dEe/9/W9K2btbkt4D7apMCCVUcfXgxKf8ADT68IGQSg6LED6mQoA5HmVo570amQDEVwYerxPwNJl7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A9ncuiz1eF2u HmZP0uoFsl5d8dYdv9rOjTKgF Vv/TPx8tt45uJg8e dWW 7RbKSQ/IDkvXBj58/t42Li4ZktiBzTOYIyCJksST51T0S01SSlEebFYsiWVz9K2/ UblJfCKFf/hcLUA6sVF1pFadjvUliPI6TrVMV43gBllKLtg1Sw5HFBtzE PcNvpQj7hy9TBXMfcOSRn3PzE4Mi uD5KV4HH96uH7HXPT5IVtfiPnfY4jxPPId8EUYHuwhORA4uOwQEIQ8JJwoQUokZBSfXRCsLmA6HsS OUIW2hEqFKCLTMs4wlRIZQqeVVcg/F5gotucCN /fcy Jd5XP94X nliZdfE514 fXV/wFtYshS1ioAAA==

Can you try this again and let me know if you're still seeing the issue?

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

No branches or pull requests

2 participants