Skip to content

Commit

Permalink
feat: auto-import createStore where used
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Feb 15, 2022
1 parent 28635a3 commit bd5ffa0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ yarn add @nuxtjs/harlem # or npm install @nuxtjs/harlem

3. Follow the [Harlem guide on how to create and use your stores](https://harlemjs.com/guide/introduction/getting-started.html#create-your-first-store).

**Note**: `createStore` will be auto-imported wherever you use it, so you don't need to import it yourself.

## Development

- Run `yarn prepare` to generate type stubs.
Expand Down
2 changes: 0 additions & 2 deletions playground/store/user.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { createStore } from '@harlem/core'

const STATE = {
firstName: 'John',
lastName: 'Smith',
Expand Down
3 changes: 2 additions & 1 deletion src/module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { resolve } from 'path'
import { fileURLToPath } from 'url'
import { defineNuxtModule, addPlugin, addTemplate } from '@nuxt/kit'
import { defineNuxtModule, addPlugin, addTemplate, addAutoImport } from '@nuxt/kit'
import { pascalCase } from 'scule'
import { genArrayFromRaw, genImport } from 'knitwork'

Expand Down Expand Up @@ -41,6 +41,7 @@ export default defineNuxtModule<ModuleOptions>({
].join('\n'),
})
addPlugin(resolve(runtimeDir, 'plugin'))
addAutoImport({ name: 'createStore', as: 'createStore', from: '@harlem/core' })
// TODO: emit native node ESM from `@harlem/*`
nuxt.options.build.transpile.push(runtimeDir, /@harlem\//)
},
Expand Down

0 comments on commit bd5ffa0

Please sign in to comment.