Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 95a1593

Browse files
committed
Enable http imports
1 parent e9cc4e7 commit 95a1593

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ This is a plugin for [Obsidian](https://obsidian.md) which enables you to use Re
3636
- [x] Works in canvas blocks.
3737
- [x] Works on mobile.
3838
- [x] Components are loaded from JS files, so you can use your favorite editor.
39-
- [x] Emera supports TypeScript, ES modules (local only), and direct import of CSS files.
39+
- [x] Emera supports TypeScript, ES modules (local and remote), and direct import of CSS files.
4040

4141
## Roadmap / What's missing
4242

@@ -127,11 +127,11 @@ Emera executes code isolated from each other. This means that by default your co
127127
Besides variables exported from code blocks, Emera put a couple of extras into page and root scope.
128128

129129
Root scope:
130-
* `app` – plugin's app instance, see [docs](https://docs.obsidian.md/Reference/TypeScript+API/App)).
130+
* `app` – plugin's app instance, see [docs](https://docs.obsidian.md/Reference/TypeScript+API/App).
131131
* `modules` – external modules provided by Emera, see [available modules](#available-modules).
132132

133133
Page scope:
134-
* `file``TFile` object for current page if rended in page, otherwise null (e.g. for blocks in canvas). See [docs](https://docs.obsidian.md/Reference/TypeScript+API/TFile)).
134+
* `file``TFile | null` object for current page if rended in page, otherwise null (e.g. for blocks in canvas). See [docs](https://docs.obsidian.md/Reference/TypeScript+API/TFile).
135135
* `frontmatter` – frontmatter object for current page.
136136

137137
### Supported features
@@ -155,7 +155,7 @@ I tried to make working with Emera as easy as possible, but there are still a fe
155155

156156
* You can't use external modules
157157

158-
Most notably, you can't use external modules (ones installed with NPM or imported directly by URL). If you're interested as to why, check out [How it works](#how-it-works) section. However, you can import local files, so if you download required library and place it in components folder – you can import it (as long as library itself doesn't import any other external modules). Emera provides a couple of modules out of the box, see [Available modules](#available-modules).
158+
Most notably, you can't use external modules installed with NPM. If you're interested as to why, check out [How it works](#how-it-works) section. However, you can import from ESM CDN like [esm.sh](https://esm.sh/). Or alternatively, you can download required library, place it in components folder and import as usual (as long as library itself doesn't import any other external modules). Emera provides a couple of modules out of the box, see [Available modules](#available-modules).
159159

160160
* You can't use built-in modules
161161

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "emera",
33
"name": "Emera",
4-
"version": "1.2.3",
4+
"version": "1.3.0",
55
"minAppVersion": "1.6.5",
66
"description": "Enables you to use custom React components and inline JavaScript, kinda like MDX.",
77
"author": "OlegWock",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-emera",
3-
"version": "1.2.3",
3+
"version": "1.3.0",
44
"description": "MDX for Obsidian. Kinda.",
55
"main": "main.js",
66
"scripts": {

src/bundler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ function importRewriter() {
3636
ImportDeclaration(path: any) {
3737
const source = path.node.source.value;
3838

39-
if (!source.startsWith('.') && !source.startsWith('/')) {
39+
const ignoredPrefixes = ['.', 'http://', 'https://'];
40+
if (!ignoredPrefixes.some(p => source.startsWith(p))) {
4041
const specifiers = path.node.specifiers;
4142

4243
const properties = specifiers.map((specifier: any) => {

src/plugin.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ export class EmeraPlugin extends Plugin {
5555
this.codeProcessor.codemirrorStateField,
5656
]);
5757

58+
// TODO: when file is renamed, we should prompt user to change its references in any Emera code block
59+
5860

5961
this.app.workspace.onLayoutReady(async () => {
6062
this.isFilesLoaded = true;

0 commit comments

Comments
 (0)