Skip to content

Import packages from arbitrary URL #437

@gyoshev

Description

@gyoshev

This is a feature request as an extension of #36 . It would be great if we could load packages that are not yet published to NPM, but are built and hosted locally.

More specifically, while developing NPM packages, our team is using SystemJS in Plunker, and using localhost URLs to fetch specific packages from the local machine (which hosts them). This allows us to author documentation and test that the examples run in StackBlitz before publishing changes to a package. More generally, this allows StackBlitz to be used during the development of the package, not only when consuming one.

Do you think that this workflow can be achieved with StackBlitz?

Activity

EricSimons

EricSimons commented on Apr 25, 2018

@EricSimons
Member

This definitely could be achieved in stackblitz- we actually had it enabled for the first few months we were online, but had to turn it off after some bundler upgrades :)

One thing that's been an issue w/ stackblitz<->local is that most folks don't have https set up for their localhost, which is a problem bc stackblitz domains are all https and thus can't access unsecured resources (i.e. http). Would this also be a blocker for you in the use case you described?

gyoshev

gyoshev commented on Apr 25, 2018

@gyoshev
Author

That’s not too inconvenient, I guess. Self-signed certificates have worked fine so far, and this can even be automated, if it is a repetitive step. It’s a small price to pay for the opportunity to test out packages before they are published :)

gyoshev

gyoshev commented on May 21, 2018

@gyoshev
Author

@EricSimons sorry to be a bother, but would this make it on the backlog? We would love to integrate this, as it will seriously simplify our code, and let us use StackBlitz on a daily basis.

If I can lend a hand in any way, please let me know. If I understand correctly this requires a change to the turbo-resolver to support local packages, but it appears that one cannot run StackBlitz locally and experiment at this point.

EricSimons

EricSimons commented on May 21, 2018

@EricSimons
Member

@gyoshev definitely- we're actually taking this use case into consideration as we've been refactoring our bundler this month. Hoping to have this all online sometime in June 👍

In the meantime, one short term solution would be manually adding a pointer to the local UMD in your stackblitz project:

SystemJS.config({
  map: {
    '@stackblitz/sdk': 'https://cdn.jsdelivr.net/npm/@stackblitz/sdk@1.2.0'
  }
})

SystemJS.import('@stackblitz/sdk').then((sdk) => {
  // Run code that requires your lib here!
  console.log('loaded SDK', sdk)
})

Lmk if you have any q's about the above & I'll keep you in the loop as we get closer to our new bundler going online!

askbeka

askbeka commented on May 2, 2019

@askbeka

any news?

oliviertassinari

oliviertassinari commented on May 15, 2022

@oliviertassinari

On MUI, we could use this feature with codesandbox CI. For instance, in https://deploy-preview-32779--material-ui.netlify.app/material-ui/react-button/#basic-button
Screenshot 2022-05-16 at 00 58 18

compare the behavior of the button when we try to use this dependency:

  "@mui/material": "https://pkg.csb.dev/mui/material-ui/commit/a1d45cd1/@mui/material",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @gyoshev@EricSimons@askbeka@oliviertassinari@purplem1lk

        Issue actions

          Import packages from arbitrary URL · Issue #437 · stackblitz/core