Uploaded image for project: 'VS Code Extension'
  1. VS Code Extension
  2. VSCODE-468

Support require of local files

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.6.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • 3
    • Not Needed
    • Iteration Lambeosaurus, Iteration Yinlong, Iteration Zephyrosaurus

       

      Original issue can be found here: https://github.com/mongodb-js/vscode/issues/595 

      Problem Statement/Rationale

      What is going wrong? What action would you like the Engineering team to take?

      It would be useful to be able to require local *.[c]js files within playgrounds in the same way it's done in regular nodeJS scripts.
      e.g 

      const myUtils = require("./utils.js"); 
      
      

      Customer Context

      We're using this extension alongside a local docker image to handle dev databases, and the utility functions we've written are both a) getting a bit much for having inside the playground file, and b) would be useful in cases to share across playgrounds.

      These utils are mostly useless to production, so including them there isn't ideal, and setting up the symlinks from our production code to a global node modules makes all of our code accessible, which we do not want. Splitting out a separate package exclusively for development helper functions is also extreme for a way to emulate native behavior.

      I have tried using the path module to get the absolute path and require it dynamically, but as __dirname is not defined the only way that would be possible is a depth-first search of the entire filesystem, which is impractical and not guaranteed to find the correct file (or for some of the data-hoarders, not even guaranteed to complete one execution before lunch).

       

            Assignee:
            basit.chonka@mongodb.com Basit Chonka
            Reporter:
            gaurab.aryal@mongodb.com Gaurab Aryal
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: