-
Notifications
You must be signed in to change notification settings - Fork 0
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
Research on tools for generating importmaps #1
Comments
Fails to import svg with the following error |
@taras what does importing svg mean? Like on-the-fly transpilation of a |
Here is an example import missingAnnotation from './components/EmptyState/assets/missingAnnotation.svg'; Webpack would put the file into the public directory and return a URL to that file. In our case, we need to generate a URL without attempting to treat it as a JS file. |
Hm.... looks like a non-standard Webpack extension In order to use this technique, the plugins do need to export valid JavaScript, so it would need to be added to the build step like the TypeScript compilation, or find another way to do it. |
I'm not sure that's true. I'm pretty sure it's just using a loader that loads static files. You can see that it's just a regular svg file https://github.com/thefrontside/backstage/blob/master/packages/core-components/src/components/EmptyState/assets/createComponent.svg I'm unsure if it's a plugin that comes with webpack, but it's pretty common. |
Yep just a plain resource loader, https://github.com/thefrontside/backstage/blob/5b381397e5b28e6371be94442ee559b4abb3fe69/packages/cli/src/lib/bundler/transforms.ts#L149. This is a custom Webpack extensions 😁 https://github.com/thefrontside/backstage/blob/5b381397e5b28e6371be94442ee559b4abb3fe69/packages/cli/src/lib/bundler/transforms.ts#L115-L137 |
By non-standard, I mean something that your browser's JavaScript engine does not understand. For example, it is also very common to import Today, Webpack is a kitchen sink that does:
Using import maps severs the latter two responsibilities and offloads them onto the browser, which I think is a major plus long term, but it does mean we still need to handle the first responsibility somehow. In this particular case, my personal preference would be to find a different way to do it (Something about publishing an ES module that assumes a path on a web server feels wrong) but in the general case, we would need to treat cases like these just like we would TypeScript: before publishing it needs to transpiled to standard JS with a tool like |
We have control over the bundles generated by Backstage CLI. We could create a new bundle that would include only the modules that browsers understand. |
The text was updated successfully, but these errors were encountered: