nuxt-nightly 4.1.2-29293784.656066cd → 4.1.2-29293810.0dcc386e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -114,7 +114,7 @@ You can use a different key or move the call to a composable to ensure the optio
114
114
  initialFetch();
115
115
  }
116
116
  const hasScope = getCurrentScope();
117
- const unsubExecute = watch([key, ...options.watch || []], ([newKey], [oldKey]) => {
117
+ const unsubKeyWatcher = watch(key, (newKey, oldKey) => {
118
118
  if ((newKey || oldKey) && newKey !== oldKey) {
119
119
  const hasRun = nuxtApp._asyncData[oldKey]?.data.value !== void 0;
120
120
  const isRunning = nuxtApp._asyncDataPromises[oldKey] !== void 0;
@@ -136,13 +136,16 @@ You can use a different key or move the call to a composable to ensure the optio
136
136
  if (options.immediate || hasRun || isRunning) {
137
137
  nuxtApp._asyncData[newKey].execute(initialFetchOptions2);
138
138
  }
139
- } else {
140
- asyncData._execute({ cause: "watch", dedupe: options.dedupe });
141
139
  }
142
140
  }, { flush: "sync" });
141
+ const unsubWatcher = options.watch ? watch(options.watch, () => {
142
+ asyncData._execute({ cause: "watch", dedupe: options.dedupe });
143
+ }) : () => {
144
+ };
143
145
  if (hasScope) {
144
146
  onScopeDispose(() => {
145
- unsubExecute();
147
+ unsubKeyWatcher();
148
+ unsubWatcher();
146
149
  unregister(key.value);
147
150
  });
148
151
  }
package/dist/index.mjs CHANGED
@@ -3650,26 +3650,11 @@ const importsModule = defineNuxtModule({
3650
3650
  virtualImports: ["#imports"],
3651
3651
  polyfills: true
3652
3652
  }),
3653
- async setup(options, nuxt) {
3653
+ setup(options, nuxt) {
3654
3654
  const presets = JSON.parse(JSON.stringify(options.presets));
3655
3655
  if (options.polyfills) {
3656
3656
  presets.push(...appCompatPresets);
3657
3657
  }
3658
- await nuxt.callHook("imports:sources", presets);
3659
- const { addons: inlineAddons, ...rest } = options;
3660
- const [addons, addonsOptions] = Array.isArray(inlineAddons) ? [inlineAddons] : [[], inlineAddons];
3661
- const ctx = createUnimport({
3662
- injectAtEnd: true,
3663
- ...rest,
3664
- addons: {
3665
- addons,
3666
- vueTemplate: options.autoImport,
3667
- vueDirectives: options.autoImport === false ? void 0 : true,
3668
- ...addonsOptions
3669
- },
3670
- presets
3671
- });
3672
- await nuxt.callHook("imports:context", ctx);
3673
3658
  let composablesDirs = [];
3674
3659
  if (options.scan) {
3675
3660
  for (const layer of nuxt.options._layers) {
@@ -3683,14 +3668,15 @@ const importsModule = defineNuxtModule({
3683
3668
  resolve(layer.config.rootDir, layer.config.dir?.shared ?? "shared", "types")
3684
3669
  );
3685
3670
  for (const dir of layer.config.imports?.dirs ?? []) {
3686
- if (!dir) {
3687
- continue;
3671
+ if (dir) {
3672
+ composablesDirs.push(resolve(layer.config.srcDir, dir));
3688
3673
  }
3689
- composablesDirs.push(resolve(layer.config.srcDir, dir));
3690
3674
  }
3691
3675
  }
3692
- await nuxt.callHook("imports:dirs", composablesDirs);
3693
- composablesDirs = composablesDirs.map((dir) => normalize(dir));
3676
+ nuxt.hook("modules:done", async () => {
3677
+ await nuxt.callHook("imports:dirs", composablesDirs);
3678
+ composablesDirs = composablesDirs.map((dir) => normalize(dir));
3679
+ });
3694
3680
  nuxt.hook("builder:watch", (event, relativePath) => {
3695
3681
  if (!["addDir", "unlinkDir"].includes(event)) {
3696
3682
  return;
@@ -3702,12 +3688,34 @@ const importsModule = defineNuxtModule({
3702
3688
  }
3703
3689
  });
3704
3690
  }
3691
+ let ctx;
3692
+ nuxt.hook("modules:done", async () => {
3693
+ await nuxt.callHook("imports:sources", presets);
3694
+ const { addons: inlineAddons, ...rest } = options;
3695
+ const [addons, addonsOptions] = Array.isArray(inlineAddons) ? [inlineAddons] : [[], inlineAddons];
3696
+ ctx = createUnimport({
3697
+ injectAtEnd: true,
3698
+ ...rest,
3699
+ addons: {
3700
+ addons,
3701
+ vueTemplate: options.autoImport,
3702
+ vueDirectives: options.autoImport === false ? void 0 : true,
3703
+ ...addonsOptions
3704
+ },
3705
+ presets
3706
+ });
3707
+ await nuxt.callHook("imports:context", ctx);
3708
+ });
3705
3709
  addTemplate({
3706
3710
  filename: "imports.mjs",
3707
3711
  getContents: async () => toExports(await ctx.getImports()) + '\nif (import.meta.dev) { console.warn("[nuxt] `#imports` should be transformed with real imports. There seems to be something wrong with the imports plugin.") }'
3708
3712
  });
3709
3713
  nuxt.options.alias["#imports"] = join(nuxt.options.buildDir, "imports");
3710
- addBuildPlugin(TransformPlugin({ ctx, options, sourcemap: !!nuxt.options.sourcemap.server || !!nuxt.options.sourcemap.client }));
3714
+ addBuildPlugin(TransformPlugin({
3715
+ ctx: { injectImports: (code, id, options2) => ctx.injectImports(code, id, options2) },
3716
+ options,
3717
+ sourcemap: !!nuxt.options.sourcemap.server || !!nuxt.options.sourcemap.client
3718
+ }));
3711
3719
  const priorities = getLayerDirectories(nuxt).map((dirs, i) => [dirs.app, -i]).sort(([a], [b]) => b.length - a.length);
3712
3720
  const IMPORTS_TEMPLATE_RE = /\/imports\.(?:d\.ts|mjs)$/;
3713
3721
  function isImportsTemplate(template) {
@@ -3744,8 +3752,11 @@ const importsModule = defineNuxtModule({
3744
3752
  filter: isImportsTemplate
3745
3753
  });
3746
3754
  };
3747
- await regenerateImports();
3748
- addDeclarationTemplates(ctx, options);
3755
+ nuxt.hook("modules:done", () => regenerateImports());
3756
+ addDeclarationTemplates({
3757
+ generateTypeDeclarations: (options2) => ctx.generateTypeDeclarations(options2),
3758
+ getImports: () => ctx.getImports()
3759
+ }, options);
3749
3760
  nuxt.hook("builder:watch", async (_, relativePath) => {
3750
3761
  const path = resolve(nuxt.options.srcDir, relativePath);
3751
3762
  if (options.scan && composablesDirs.some((dir) => dir === path || path.startsWith(dir + "/"))) {
@@ -3811,7 +3822,7 @@ function addDeclarationTemplates(ctx, options) {
3811
3822
  });
3812
3823
  }
3813
3824
 
3814
- const version = "4.1.2-29293784.656066cd";
3825
+ const version = "4.1.2-29293810.0dcc386e";
3815
3826
 
3816
3827
  const createImportProtectionPatterns = (nuxt, options) => {
3817
3828
  const patterns = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-nightly",
3
- "version": "4.1.2-29293784.656066cd",
3
+ "version": "4.1.2-29293810.0dcc386e",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -67,10 +67,10 @@
67
67
  "@nuxt/cli": "npm:@nuxt/cli-nightly@latest",
68
68
  "@nuxt/devalue": "^2.0.2",
69
69
  "@nuxt/devtools": "^2.6.3",
70
- "@nuxt/kit": "npm:@nuxt/kit-nightly@4.1.2-29293784.656066cd",
71
- "@nuxt/schema": "npm:@nuxt/schema-nightly@4.1.2-29293784.656066cd",
70
+ "@nuxt/kit": "npm:@nuxt/kit-nightly@4.1.2-29293810.0dcc386e",
71
+ "@nuxt/schema": "npm:@nuxt/schema-nightly@4.1.2-29293810.0dcc386e",
72
72
  "@nuxt/telemetry": "^2.6.6",
73
- "@nuxt/vite-builder": "npm:@nuxt/vite-builder-nightly@4.1.2-29293784.656066cd",
73
+ "@nuxt/vite-builder": "npm:@nuxt/vite-builder-nightly@4.1.2-29293810.0dcc386e",
74
74
  "@unhead/vue": "^2.0.14",
75
75
  "@vue/shared": "^3.5.21",
76
76
  "c12": "^3.2.0",