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

Resolve radash module & upgrade nuxt to the latest #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground"
},
"dependencies": {
"@nuxt/kit": "^3.6.5",
"@nuxt/kit": "^3.7.3",
"radash": "^11.0.0"
},
"devDependencies": {
"@nuxt/devtools": "latest",
"@nuxt/eslint-config": "^0.1.1",
"@nuxt/module-builder": "^0.4.0",
"@nuxt/schema": "^3.6.5",
"@nuxt/test-utils": "^3.6.5",
"@nuxt/schema": "^3.7.3",
"@nuxt/test-utils": "^3.7.3",
"@nuxtjs/eslint-config-typescript": "latest",
"@types/node": "^18.17.0",
"eslint": "latest",
"nuxt": "^3.6.0"
"nuxt": "^3.7.3"
}
}
10 changes: 6 additions & 4 deletions src/module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { addImports, defineNuxtModule } from "@nuxt/kit";
import * as radash from "radash";
import { addImports, createResolver, defineNuxtModule } from "@nuxt/kit";
import * as radash from "./runtime/radash";

export interface ModuleOptions {
/**
Expand Down Expand Up @@ -48,7 +48,9 @@ export default defineNuxtModule<ModuleOptions>({
alias: [],
upperAfterPrefix: true,
},
setup(options, nuxt) {
setup(options) {
const { resolve } = createResolver(import.meta.url);

const aliasMap = new Map<string, string>(options.alias);
const prefixSkip = options.prefixSkip
? radash.isArray(options.prefixSkip)
Expand All @@ -63,7 +65,7 @@ export default defineNuxtModule<ModuleOptions>({
const as = prefix
? prefix + (options.upperAfterPrefix ? radash.pascal(alias) : alias)
: alias;
addImports({ name, as, from: "radash" });
addImports({ name, as, from: resolve("./runtime/radash") });
Copy link
Author

@lukasaric lukasaric Sep 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi, Tried to use findPath + resolve from nuxt/kit to directly resolve radash here, but it seems that it does not work. That's why I just exported everything through ./runtime/radash.ts file and resolved it on my own.

}
},
});
1 change: 1 addition & 0 deletions src/runtime/radash.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "radash";
Loading