Accessing engine stores from plugins?

Attempting to build a stat assignment/character build screen using a custom plugin. I will admit I am new to typescript and pina and more advanced javascript programming in general. I’m a database guy whose done some front end javascript, so I’m out of my depth but trying to learn by the sink or swim method.

When I attempt to import a constant to execute its methods (in this case, to get and modify skill values) I get this error:

[plugin:vite:import-analysis] Failed to resolve import “…/node_modules/narrat/dist/stores/skills” from “src\counter-ui.vue”. Does the file exist?


1 | import { computed, defineComponent } from “vue”;
2 | import { useCounter } from “./custom-stores/counter-store”;
3 | import { useSkills } from “…/node_modules/narrat/dist/stores/skills”;
| ^
4 | const _sfc_main = defineComponent({
5 | setup() {

at formatError (file:///E:/narrat/narrat-game/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:44062:46)
at TransformContext.error (file:///E:/narrat/narrat-game/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:44058:19)
at normalizeUrl (file:///E:/narrat/narrat-game/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:41844:33)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async file:///E:/narrat/narrat-game/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:41998:47
at async Promise.all (index 2)
at async TransformContext.transform (file:///E:/narrat/narrat-game/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:41914:13)
at async Object.transform (file:///E:/narrat/narrat-game/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:44352:30)
at async loadAndTransform (file:///E:/narrat/narrat-game/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:55026:29)
at async viteTransformMiddleware (file:///E:/narrat/narrat-game/node_modules/vite/dist/node/chunks/dep-41cf5ffd.

Is accessing the engine stores from a plugin even possible or am I barking up the wrong tree.

You shouldn’t import file paths directly from node modules, it won’t work, especially with typescript.

You can only import what’s exported by narrat. I think I’ve put stores in the exports list but not sure.

So this should work:

import { useSkills } from 'narrat';

You can also see all the exports in this folder: narrat-engine/packages/narrat/src/exports at main · liana-p/narrat-engine · GitHub

exports.ts exports the other files in there which themselves export a bunch of narrat things, that can all be imported from narrat


That did the trick, thank you! :smiley: Appreciate the instruction. Still trying to wrap my head around the data structure.

Ah! There it is! I was looking everywhere for these hooks.

Thanks again! And thanks for making this engine, its really cool!