Skip to content

Roadmap to v1.0.0 #449

Closed
Closed
@danielroe

Description

@danielroe

With the release of unbuild v3, the EOL status of Nuxt 2, and looking forward to Nuxt 4, we're going to take the opportunity to release v1 of @nuxt/module-builder, with a range of breaking changes.

🧪 Testing v1

It is possible to try out the current state of the module builder by installing @nuxt/module-builder@alpha. (Expect breaking changes if you are trying out the alpha release.)

⚠️ Breaking Changes

  • Upgrade to unbuild v3 (#447)
    This major upgrade brings significant changes to the build proces but should be significantly better.

  • Removal of Node10 module resolution and CommonJS output (#448)
    As Nuxt 2 has reached EOL, we no longer generate CJS by default, and we have also removed the 'CJS bridge' feature that polyfilled __filename and __dirname.

🚧 Migration Guide

Replacing __filename and __dirname

We no longer polyfill these CommonJS variables. Instead, use the createResolver utility from @nuxt/kit:

import { createResolver } from '@nuxt/kit'

// Instead of __dirname and __filename
const resolver= createResolver(import.meta.url)
const runtimeDir = resolver.resolve('./runtime')

Module Resolution Changes

We no longer officially support Node10 module resolution, meaning you should remove the types/type field from your package.json. If you need to maintain compatibility with older Node.js versions or systems expecting CommonJS, you can use the typesVersions field in your package.json.

This field allows typing subpath exports (like my-module/utils) even with older moduleResolution settings. Regardless, we recommend all Nuxt users to use Bundler module resolution.

{
  "typesVersions": {
    "*": {
      ".": [
        "dist/index.d.mts"
      ],
      "some-subpath": [
        "dist/some-subpath.d.mts"
      ]
    }
  }
}

ESM-only Output

We no longer generate CommonJS (.cjs) output files by default, as this was primarily needed for Nuxt 2 compatibility. You should:

  • Set "type": "module" in your package.json
  • Update any mentions of .cjs files in your package.json

For example:

+ "type": "module",
  "exports": {
-   ".": {
      "types": "./dist/types.d.mts",
      "import": "./dist/module.mjs",
-     "require": "./dist/module.cjs"
-   },
-   "./utils": {
-     "types": "./dist/utils.d.mts",
-     "import": "./dist/utils.mjs",
-     "require": "./dist/utils.cjs"
+   "./utils": "./dist/utils.mjs"
  },
- "main": "./dist/module.cjs",
+ "main": "./dist/module.mjs",
- "types": "./dist/module.d.mts",
+ "typesVersions": {
+   "*": {
+     ".": [
+       "./dist/types.d.mts"
+     ],
+     "utils": [
+       "./dist/utils.d.mts"
+     ]
+   }
+ },
  "files": [
-   "utils.d.ts"
    "dist"
  ],

Configuring unbuild

You can still customize the build process by extending the unbuild configuration in your buildOptions.

To customize/extend the unbuild configuration you can add a build.config.ts in the root of your project:

import { defineBuildConfig } from 'unbuild'

export default defineBuildConfig({
  // set additional configuration or customize using hooks
  rollupOptions: {
    // for example, if you wish to continue to generate `.cjs` output
    emitCJS: true
  }
})

✨ Changelog

compare changes

🚀 Enhancements

  • ⚠️ Upgrade to unbuild v3 (#447)
  • ⚠️ Remove support for node10 resolution + cjs (#448)
  • build: Ignore test + story files in runtime/ directory (#480)
  • Add support for type exports in module re-exports (#563)

🩹 Fixes

  • Mark nuxi as optional peerDep (29a42ae)
  • Drop @nuxt/kit peer dependency & remove optionality for nuxi (5936063)
  • build: Handle windows path names (#399)
  • build: Apply resolved tsconfig to dts (#462)
  • Handle node10 resolution + add attw test (7309198)
  • Update warnings (6291cbe)
  • Support more than one line of type exports (0c0020f)
  • Split re-exports across multiple lines (7154a89)
  • Support star exports (8966047)

📖 Documentation

  • Update example build script (#359)
  • Update link to downloads count badge (9804e9e)
  • Describe configuring unbuild (#440)

🏡 Chore

  • Use tinyexec in test suite (7ff8ef1)
  • Fix links (2e57eb2)
  • Pin typescript until issue with vue-tsc is resolved (994135d)
  • Bump vue-tsc (e8cb0ef)
  • Bump nuxi version (5b1f00e)
  • Add publint to dev dependencies (7281ae3)
  • Set node versions and enable knip (1a17c0c)
  • Stub module before stubbing playground (b3a513b)
  • Run install command to relink binaries (932729e)
  • Update command and add builder to workspace (#482)
  • Add type assertion (14d7788)
  • Add more type-safe solution + fallback (66d4231)
  • Add pkg.pr.new for nightly/pr builds (#573)
  • Bump to latest mkdist and add vue-sfc-transformer (673152a)
  • Update knip config (c9a28a0)

✅ Tests

  • Await file snapshot assertions (16930b4)
  • Assert current vue snapshot behaviour (#444)
  • Update snapshots (847d150)

🤖 CI

  • Don't run publint on windows (330f412)
  • Prepare environment in lint step (5f0f88f)
  • Force latest corepack (9d74ce4)

⚠️ Breaking Changes

  • ⚠️ Upgrade to unbuild v3 (#447)
  • ⚠️ Remove support for node10 resolution + cjs (#448)

❤️ Contributors

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions