You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+29Lines changed: 29 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,6 +96,35 @@ console.log(myCode);
96
96
// Outputs the content of 'example.js' as a string.
97
97
```
98
98
99
+
### Good News:
100
+
101
+
With the latest update, you no longer need to specify the file extension explicitly.
102
+
103
+
```js
104
+
importmyCodefrom"./example?raw";
105
+
```
106
+
107
+
This works seamlessly! Additionally, if you're exporting from files like `index.tsx`, `index.jsx`, etc., you can simplify imports. For example, if your file path is `my-lib/index.ts`, you can import the raw content like this:
108
+
109
+
```js
110
+
importmyCodefrom"./my-lib?raw";
111
+
```
112
+
113
+
### Extension Options (Optional)
114
+
115
+
```ts
116
+
exportinterfaceRawPluginOptions {
117
+
/**
118
+
* Extensions to check in order if the file does not exist.
119
+
* If it's a directory, the plugin will look for `dir/index.[ext]`.
"description": "An ESBuild and TSUP plugin that allows importing files as raw text. Useful for loading code files in documentation, interactive demos, or tools like react-live.",
`File not found: ${args.pluginData}\nWe checked for following extensions: ${ext.join(", ")}. You can customise by passing {ext: [...]} to raw({ext:[...]})`,
0 commit comments