Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import a script inside a component or api cause an error #107

Closed
RoXuS opened this issue Jan 28, 2021 · 10 comments
Closed

Import a script inside a component or api cause an error #107

RoXuS opened this issue Jan 28, 2021 · 10 comments
Labels
✘ bug Something isn't working

Comments

@RoXuS
Copy link

RoXuS commented Jan 28, 2021

Hey!

I'm trying to call a script outside my aleph project (I am on a monorepo project).

import React from "https://esm.sh/react";
import a from "../../dt-gitlab-wrapper/index.ts";

const b = new a("1");

export default function Runners() {
...
}

When I do that I get the following error:
image

It's normal behavior? We can't call a script outside the component?

@RoXuS RoXuS changed the title Import of a script inside a component or api cause an error Import a script inside a component or api cause an error Jan 28, 2021
@shadowtime2000
Copy link
Member

I would call this normal behavior because you should only be importing stuff from CDNs and from within the project folder. It does make the situation a little ugly for monorepos though, monorepos with deno is something that is still being figured out though anyways.

@Soremwar
Copy link

You only use "../" or "./" relative paths when the file exists locally in your machine. If it doesn't then you should be using an URL to import from wherever you have it

@RoXuS
Copy link
Author

RoXuS commented Jan 29, 2021

hum my other projects inside the monorepo work well (install, bundle...).
I don't understand why a TS file inside my project works and just above is KO?

With a symlink of the external project inside root of aleph project, it is ok.

@FallingSnow
Copy link
Contributor

This might be due to the fact that alephjs movies files around before executing them. I know this isn't an import but this is how I access files.

import * as path from "https://deno.land/[email protected]/path/mod.ts";

const dir = path.fromFileUrl(import.meta.url);
const projectDir = path.resolve(dir, "../../../../"); // The files are located in the same directory (api), but in order to work, you need to move up 4 directories for the project root directory.
const schemaFilePath = path.resolve(projectDir, "api/schema.gql");

Deno.readTextFileSync(schemaFilePath);

@Soremwar
Copy link

@RoXuS Can you please show your project structure? I feel like I am giving advise without actually knowing what I'm dealing with

@RoXuS
Copy link
Author

RoXuS commented Jan 29, 2021

@Soremwar off course.

My structure:
image

My components/runners.tsx try to access to dt-gitlab-wrapper/index.ts and it doesn't work (with a symlink it is ok).

@FallingSnow it seems hard to do that with a file import like import a from "../../dt-gitlab-wrapper/index.ts"; no?

@FallingSnow
Copy link
Contributor

Yeah. I don't know if deno supports require, I've never tried but that could be a possible solution.

@ije
Copy link
Member

ije commented Jan 30, 2021

i seems the git-wrapper is out of your aleph app scope that alephjs can't handle it, I will fix this, thanks!

@ije ije added the ✘ bug Something isn't working label Jan 30, 2021
@ije
Copy link
Member

ije commented Jan 30, 2021

please use synlimk as workaround currently

@RoXuS
Copy link
Author

RoXuS commented Mar 6, 2021

works as expected on 1.8.0, THX!

@RoXuS RoXuS closed this as completed Mar 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✘ bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants