jspm / project

Roadmap and management repo for the jspm project
161 stars 8 forks source link

[generator] TypeError: Failed to fetch dynamically imported module: https://ga.jspm.io/npm:@babel/core@7.23.2/lib/index.js #326

Open trusktr opened 8 months ago

trusktr commented 8 months ago

generator fails to generate for pota package:

https://generator.jspm.io/#M2NhYGBkDM0rySzJSU1hKMgvSXQw0DPRM7EAANczdlIaAA

guybedford commented 8 months ago

The error is obscure, and that is due to an unrelated bug. Specifically that it's trying to do TypeScript parsing. I've created https://github.com/jspm/generator/pull/340 to disable TypeScript parsing in the generator.

The package issue in this case though is that they have published raw .ts and .tsx files to npm that are being loaded, which won't be supported in browsers of course.

Once https://github.com/jspm/generator/pull/340 is landed and released in the generator app, the error should at least improve a bit.

trusktr commented 8 months ago

The pota package does not publish TypeScript files. In fact, it is written in plain JS, and the .d.ts declaration files are generated (those are the only files generated, the source is .js). The exports field points to .js files:

https://unpkg.com/browse/pota@0.7.77/package.json

I can load pota by writing a manual importmap that points to unpkg:

<script type="importmap">
    {
        "imports": {
            "solid-js": "https://unpkg.com/solid-js@1.8.11/dist/solid.js",
            "solid-js/dist/solid.js": "https://unpkg.com/solid-js@1.8.11/dist/solid.js",
            "solid-js/web": "https://unpkg.com/solid-js@1.8.11/web/dist/web.js",
            "solid-js/html": "https://unpkg.com/solid-js@1.8.11/html/dist/html.js",
            "solid-js/store": "https://unpkg.com/solid-js@1.8.11/store/dist/store.js",

            "pota": "https://unpkg.com/pota@0.7.65/src/exports.js",
            "pota/": "https://unpkg.com/pota@0.7.65/"
        }
    }
</script>

Live demo on CodePen

guybedford commented 8 months ago

That was not the case for the 0.4 version of Pota, so it was likely a publishing mistake that they published JSX. Retesting on the latest version it appears to generate correctly now -

https://generator.jspm.io/#M2NhYGBkDM0rySzJSU1hKMgvSXQw0DPXM7cEAGz/6RwaAA