Giter Site home page Giter Site logo

nuxt-lodash's Introduction

Lodash for Nuxt

Version License Types

πŸ’‘ About

Lodash auto-import module for Nuxt.

πŸ“¦ Install

  1. Install nuxt-lodash as development dependency:
npm i nuxt-lodash -D
  1. Add it to the modules section of your nuxt.config:
export default defineNuxtConfig({
  modules: ["nuxt-lodash"],
});

πŸš€ Example

Use any Lodash methods in your Nuxt application, they will be auto-imported!

<script setup>
  const text = useToUpper("it works!");
</script>

<template>
  <div>{{ text }}</div>
</template>

πŸ”¨ Config

Name Default Description
prefix 'use' String to prepend before each Lodash function (false to disable)
prefixSkip 'is' Functions that starts with this keywords will be skipped by prefix (false to disable)
upperAfterPrefix true If true it will automatically uppercase first letter after prefix (false to disable)
exclude [] Array of Lodash functions to exclude from auto-imports
alias [] Array of array pairs to rename specific Lodash functions (prefix is still added)

πŸ’» Example - Config

export default defineNuxtConfig({
  modules: ["nuxt-lodash"],
  lodash: {
    prefix: "_",
    prefixSkip: ["string"],
    upperAfterPrefix: false,
    exclude: ["map"],
    alias: [
      ["camelCase", "stringToCamelCase"], // => stringToCamelCase
      ["kebabCase", "stringToKebab"], // => stringToKebab
      ["isDate", "isLodashDate"], // => _isLodashDate
    ],
  },
});

πŸ“„ License

MIT License © 2021-2022 - Michal Čípa

nuxt-lodash's People

Contributors

atinux avatar cipami avatar daniil4udo avatar marshallswain avatar renovate[bot] avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nuxt-lodash's Issues

`prefixSkip` option injects 'is' by default

Hi.

I think module should not provide array defaults, because it leads to cases where you cannot disable it completely.
For now for example i cannot alias check-functions (isFinite, isBuffer e.t.c) as _isFinite even if i set prefixSkip: [].

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Location: renovate.json
Error type: Invalid JSON (parsing failed)
Message: Syntax error: expecting end of expression or separator near ":dis

Nuxt renamed useMeta to useHead and somehow this clashes

Nuxt renamed useMeta to useHead and somehow this clashes.

const useMeta: typeof import('../../node_modules/nuxt3/dist/head/runtime')['useMeta'] // deprecated
...
const useHead: typeof import('lodash-es')['head']

Temp fix

For now i added exclude: ['head'],
which results in

  const useHead: typeof import('../../node_modules/nuxt3/dist/head/runtime')['useHead']
  const useMeta: typeof import('../../node_modules/nuxt3/dist/head/runtime')['useMeta']

Added a comment in the breaking changes section

Using inside script

Can this be used inside the script tag at all?

something like this.useOrderBy(...)

Named export 'debounce' not found in production

Hello,
I am trying to use the debounce function on a watch method and that's the code used.

watch(() => filterPayout.value, useDebounce(() => fetch(), 500), { deep: true })

The project works fine locally but once i build the project for production this error appears
image

the project was built using Nuxt 3.0.0 on a CPanel Linux env.

RC11

Could you upgrade deps to rc11?

Not available on the server side?

On the server side, whenever I use nuxt-lodash (exmaple useUniq) it says it's not defined (even tho it;s installed and the the IDE picks it up fine).

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: Using npm packages for Renovate presets is now deprecated. Please migrate to repository-based presets instead.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/release.yml
  • actions/checkout v3
  • actions/setup-node v3
  • pnpm/action-setup v2.4.0
npm
package.json
  • @nuxt/kit ^3.8.0
  • @types/lodash-es ^4.17.10
  • lodash-es ^4.17.21
  • @semantic-release/git ^10.0.1
  • conventional-changelog-conventionalcommits ^5.0.0
  • nuxt ^3.8.0
  • semantic-release ^20.1.3
  • pnpm 8.9.2

  • Check this box to trigger a request for Renovate to run again on this repository

Many imports in dev

Version: 2.5.0
Nuxt: 3.6.0
Hi! I found closed issue about many imports in dev mode #47
And it's still present in last version
image

error when using chain syntax in static site (ssr: false)

Hi there,

Just wondering does this plug-in support chain syntax? e.g. useChain(myArray).find({id: 2}).get("val").value()

I am facing a very strange issue, the code running fine when in Dev mode but not in production. Once SPA site generated, it doesn't like chain syntax. The error pops up as below:
TypeError: (intermediate value)(intermediate value)(intermediate value)(...).find is not a function

Nuxt3 example code - example.vue

<template>
  <div>
    <p>{{ useChain(myArray).find({id: 2}).get("val").value() }}</p>
    <p>{{ filtered }}</p>
  </div>
</template>

<script setup lang="ts">
const myArray = ref([{id:1, val:"test1"},{id:2, val:"test2"}]),
      filtered = computed( () => useChain(myArray.value).find({id: 1}).get("val").value() );

</script>

Hopefully, someone can guide me to solve this issue, maybe a config problem??

Cheers

Uppercased prefixed functions

With current options it's impossible to easely prefix all functions like that: _map, _pick etc.
Could we implement this as uppercase option with true as default for example?

question about optimizeDeps.exclude

I want to know why exclude optimizeDeps lodash-es in vite:extend

This cause so many dynamic import in dev, like this:

image

Just a question, thank you.

EError

Hi,

I have this issue with Nuxt3
"nuxt-lodash": "^2.4.1",
"nuxt": "3.0.0",

When page loaded

Capture d’écran 2023-01-27 aΜ€ 18 36 57

lodash: {
		prefix: "_",
		prefixSkip: ["string"],
		upperAfterPrefix: false,
		exclude: ["map"],
		alias: [
		  ["camelCase", "stringToCamelCase"], // => stringToCamelCase
		  ["kebabCase", "stringToKebab"], // => stringToKebab
		  ["isDate", "isLodashDate"], // => _isLodashDate
		],
	  },
	modules: [
		'@nuxtjs/apollo',
		'@nuxtjs/tailwindcss',
		'nuxt-lodash',
		'@nuxtjs/i18n',
		[ ....

Thanks :)

Typo in module.ts

New to contributing, I think this is the correct way to suggest a change but apologies if not.

In "src/module.ts" there are a few typos, it doesn't affect functionality but could cause a future hiccup.

Current (Line 3):

import exculdeDefaults from './exclude'

Suggested (Line 3):

import excludeDefaults from './exclude'

Current (Line 61):
const exludes = [...options.exclude, ...exculdeDefaults]

Suggested (Line 61):
const excludes = [...options.exclude, ...excludeDefaults]

Current (Line 65):
if (!exludes.includes(name)) {

Suggested (Line 65):
if (!excludes.includes(name)) {

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.