0.0.126 • Published 2 years ago

@fwoosh/styling v0.0.126

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@fwoosh/virtual-file

Utility function to help create virtual files for fwoosh. Enables authoring in TS but being loaded in a virtual files as plain JS.

Usage

The following will load the contents of my-file.ts as ESM JS.

import { loadVirtualFile } from "@fwoosh/virtual-file";
import { createRequire } from "module";

const require = createRequire(import.meta.url);

// NOTE: Use the .js extension even if it's .ts
await loadVirtualFile(require.resolve("./my-file.js"));

Variables

You can inject variables into loaded files by using process.env.YOUR_VARIABLE in your file.

Give this file:

export function getVariable() {
  return process.env.YOUR_VARIABLE;
}

And this usage:

await loadVirtualFile(require.resolve("./my-file.js"), {
  YOUR_VARIABLE: 1000,
});

The virtual file will be:

export function getVariable() {
  return 1000;
}
0.0.119

2 years ago

0.0.118

2 years ago

0.0.126

2 years ago

0.0.125

2 years ago

0.0.120

2 years ago

0.0.124

2 years ago

0.0.123

2 years ago

0.0.122

2 years ago

0.0.121

2 years ago

0.0.117

2 years ago

0.0.84

2 years ago

0.0.116

2 years ago

0.0.85

2 years ago

0.0.115

2 years ago

0.0.86

2 years ago

0.0.114

2 years ago

0.0.87

2 years ago

0.0.88

2 years ago

0.0.89

2 years ago

0.0.113

2 years ago

0.0.112

2 years ago

0.0.111

2 years ago

0.0.82

2 years ago

0.0.110

2 years ago

0.0.83

2 years ago

0.0.106

2 years ago

0.0.95

2 years ago

0.0.105

2 years ago

0.0.96

2 years ago

0.0.104

2 years ago

0.0.97

2 years ago

0.0.103

2 years ago

0.0.98

2 years ago

0.0.99

2 years ago

0.0.109

2 years ago

0.0.108

2 years ago

0.0.107

2 years ago

0.0.90

2 years ago

0.0.102

2 years ago

0.0.91

2 years ago

0.0.101

2 years ago

0.0.92

2 years ago

0.0.100

2 years ago

0.0.93

2 years ago

0.0.94

2 years ago

0.0.81

2 years ago

0.0.80

2 years ago

0.0.79

2 years ago

0.0.78

2 years ago

0.0.77

2 years ago

0.0.76

2 years ago