Skip to content

VanillaMaster/babel-plugin-inline-import-attributes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@vanilla/babel-plugin-inline-import-attributes

Babel plugin to inline text imports with type import attribute set to inline/text

installation

npm install git+https://github.com/VanillaMaster/babel-plugin-inline-import-attributes.git

TIP: use #semver:<semver> syntax

module specifier resolution algorithm

import-meta-resolve package used as esm resolution algorithm implementation

example

// @filename: before.js
import text from "./data.txt" with { type: "inline/text" }

// @filename: after.js
const text = "content of ./data.txt"
// @filename: before.js
import * as module from "./data.txt" with { type: "inline/text" }

// @filename: after.js
const module = Object.create(null, {
    default: {
        value: "content of ./data.txt",
        configurable: false,
        writable: false,
        enumerable: true
    },
    [Symbol.toStringTag]: {
        value: "Module",
        configurable: false,
        writable: false,
        enumerable: false
    }
});
// @filename: before.js
import text, * as module from "./data.txt" with { type: "inline/text" }

// @filename: after.js
const module = Object.create(null, {
    default: {
        value: "content of ./data.txt",
        configurable: false,
        writable: false,
        enumerable: true
    },
    [Symbol.toStringTag]: {
        value: "Module",
        configurable: false,
        writable: false,
        enumerable: false
    }
}), text = module.default;

About

Babel plugin to embed imports marked as inline by import attribute

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published