How to import a library

Hey Retool,

I am trying to import a package into my app to do intelligent parsing of phone numbers.
Its called libphonenumber-js.

Adding the /min-js/ to the libraries didn't seem to help.

Pasting the whole JavaScript code blob into the preloaded code also didn't seem to work.

I imported this one using the library manager:

Then I put this into the Preloaded JS. It was not apparent to me that the libphonenumber variable was in the state.

var scrape=libphonenumber.findPhoneNumbersInText;

Then I can make a variable like this:

  //  var x=libphonenumber;
  //  var foo=libphonenumber.findPhoneNumbersInText;
  var foo=scrape;
  //  return JSON.stringify(''+foo)
  var x='';
  x= foo(`
  For tech support call +7 (800) 555-35-35 internationally
  or reach a local US branch at (213) 373-4253 ext. 1234.
`, 'US')
  //  x=libphonenumber;
  return JSON.stringify(x);

The result looks like


Its amazing!