Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

feat(nuxt): add onBeforeRouteLeave and onBeforeRouteUpdate composables #8889

Merged
merged 3 commits into from
Nov 10, 2022
Merged
Changes from 1 commit
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
Next Next commit
fix(nuxt): prevent sharing sources between invocations
  • Loading branch information
danielroe committed Nov 10, 2022
commit edec9602503051623b53e1a812c9715a94b1bcb4
11 changes: 7 additions & 4 deletions packages/nuxt/src/imports/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,26 @@ export default defineNuxtModule<Partial<ImportsOptions>>({
options = defu(nuxt.options.autoImports, options)
}

// TODO: fix sharing of defaults between invocations of modules
const presets = JSON.parse(JSON.stringify(options.presets)) as ImportPresetWithDeprecation[]

// Allow modules extending sources
await nuxt.callHook('imports:sources', options.presets as ImportPresetWithDeprecation[])
await nuxt.callHook('imports:sources', presets)

options.presets?.forEach((_i) => {
for (const _i of presets) {
const i = _i as ImportPresetWithDeprecation | string
if (typeof i !== 'string' && i.names && !i.imports) {
i.imports = i.names
logger.warn('imports: presets.names is deprecated, use presets.imports instead')
}
})
}

// Filter disabled sources
// options.sources = options.sources.filter(source => source.disabled !== true)

// Create a context to share state between module internals
const ctx = createUnimport({
presets: options.presets,
presets,
imports: options.imports,
virtualImports: ['#imports'],
addons: {
Expand Down