Skip to content

longshotlabs/import-as-string

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

import-as-string

Import the contents of any file into a Node.js ES module as a string.

Installation

npm install import-as-string

Usage

import importAsString from "import-as-string";
const schema = importAsString("./schema.graphql");

console.log(typeof schema); // "string"

Arguments

importAsString accepts two arguments:

  • specifier: Required. The file to import. May be a relative or absolute path, a file in an NPM package, etc.
  • encoding: Optional. If the encoding of the file being imported from isn't UTF8, specify the encoding.

About

Import the contents of any file into a Node.js ES module as a string

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published