Package Exports
- inline-import
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (inline-import) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Inline Import
This tool inlines custom file imports.
Use Case
Instead of loading external files during runtime, you may wish to integrate the raw file contents directly into your JavaScript files during build time. The type of the external files is irrelevant.
Usage
The inlining process is destructive. Affected files will be changed permanently.
To inline your file imports, you need to specify the path to the JavaScript
file that should be modified. Additionally, you need to define the
extensions of the relevant import statements.
text.txt
hello worldindex.js
import stuff from "garage";
import text from "./text.txt";inline.js
import InlineImport from "inline-import";
InlineImport.transform("index.js", {
extensions: {
".txt": "utf8"
}
});index.js (inlined)
import stuff from "garage";
const text = "hello world";Options
- You may define a specific
encodingfor the JavaScript files that should be processed. Use one of the possible encoding values specified in node's Buffer class. The default encoding is utf8. - Only imports with matching file
extensionswill be considered. Each extension must define its own encoding. - If, for some reason, you don't want to use the const statement, set
useVarto true.
InlineImport.transform(file, {
encoding: "utf8",
useVar: true,
extensions: {
".html": "utf8",
".png": "base64"
}
});Contributing
Maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.