halvardssm / deno-nessie

A modular Deno library for PostgreSQL, MySQL, MariaDB and SQLite migrations
MIT License
527 stars 31 forks source link

[Bug]: Using nessie with import maps #135

Closed Druue closed 3 years ago

Druue commented 3 years ago

Operating System

Win10

Deno version

1.13.2

Nessie version

2.0.1

Bug description

TypeError: Relative import path "nessie" not prefixed with / or ./ or ../ from "file:///C:/Users/user/workspace/nessie.config.ts"

nessie.config.ts

import {
    ClientSQLite,
    NessieConfig,
} from "nessie";

const client = new ClientSQLite("./src/sqlite.db");

/** This is the final config object */
const config: NessieConfig = {
    client,
    migrationFolders: ["./db/migrations"],
    seedFolders: ["./db/seeds"],
};

export default config;

Steps to reproduce

Fresh Deno project using import-maps - import_map.json

{
  "imports": {
    "fmt/": "https://deno.land/std@0.106.0/fmt/",
    "http/": "https://deno.land/std@0.106.0/http/",
    "nessie": "https://deno.land/x/nessie@2.0.1/mod.ts",
    "sqlite": "https://deno.land/x/sqlite@v3.1.1/mod.ts"
  }
}

Install nessie CLI utility.

deno install -A --unstable -n nessie --no-check https://deno.land/x/nessie/cli.ts

Attempt to generate migration:

nessie make:migration name

Aditional information

No response

ebebbington commented 3 years ago

@Druue Nessie (afaik) isn't aware that you want to use an import map, i'm guessing nessie would need to provide a flag where you can pass in the path to your import map

halvardssm commented 3 years ago

Hello @Druue ! Exactly as @ebebbington said: Nessie is not built with import maps in mind.

Import maps are currently unstable/not fully implemented, so this might change in the future once import maps have matured a bit. For now, I suggest using a deps.ts file, or using the URL import directly 😊

halvardssm commented 3 years ago

As this is not a bug, I will transfer this issue to discussions