Releases: nuxt/module-builder
v1.0.1
v1.0.0
With the release of unbuild v3, the EOL status of Nuxt 2, and looking forward to Nuxt 4, we're taking the opportunity to release v1 of @nuxt/module-builder
, with a range of breaking changes.
⚠️ 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
. -
Type errors. The module builder will now error if there are type errors when generating your
runtime/*
files. (Previously warnings were logged but your build would have succeeded.) Errors you receive aren't caused by the upgrade, but you might need to correct any issues before your module will build again.
🚧 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 yourpackage.json
For example:
+ "type": "module",
"exports": {
".": {
- "types": "./dist/types.d.ts",
+ "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.ts",
+ "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
🚀 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)
- Bump vue-sfc-transformer version (3cd9cd4)
- release: V1.0.0 (b0655d3)
✅ 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
❤️ Contributors
- Daniel Roe (@danielroe)
- Dev (@productdevbook)
- Bobbie Goede (@BobbieGoede)
v0.8.4
v0.8.3
v0.8.2
🔥 Performance
- Removed unnecessary hasTypeExport check (#310)
🩹 Fixes
- prepare: Override
compatibilityDate
(b9b27c3)
❤️ Contributors
- Daniel Roe (@danielroe)
- Matt (@matt-clegg)
v0.8.1
🩹 Fixes
- build: Export all types in stub mode (6b1970d)
🏡 Chore
- Add @danielroe to code owners (c39cc75)
❤️ Contributors
- Daniel Roe (@danielroe)
v0.8.0
🩹 Fixes
⚠️ Do not augment nuxt options inside module entry (#295)- build: Do not export default as a type (d29337c)
- build: Only generate
import type
statement if required (190bff4)
⚠️ Breaking Changes
⚠️ Do not augment nuxt options inside module entry (#295)
❤️ Contributors
- Daniel Roe (@danielroe)
v0.7.1
🩹 Fixes
- build: Declare
ModuleOptions
in correct place (#283)
📖 Documentation
- Update path for runtime js files (#282)
❤️ Contributors
- Adam DeHaven (@adamdehaven)
- Daniel Roe (@danielroe)
v0.7.0
🚀 Enhancements
- Auto generate module options from schema meta (#33)
🩹 Fixes
- Use
tsconfck
to resolve tsconfigcompilerOptions
(#274) ⚠️ Use.js
extension for files inruntime/
directory (dbd05bb)- Resolve full path to runtime externals (#275)
- Include
dist/runtime
in externals list (0946c04)
📖 Documentation
- Add
types
condition to export subpath (#265)
🏡 Chore
✅ Tests
- Add additional test for validity of types shared from runtime (afc4374)
🤖 CI
- Adds reproduction workflow (0dc73bb)
⚠️ Breaking Changes
⚠️ Use.js
extension for files inruntime/
directory (dbd05bb)
❤️ Contributors
- Daniel Roe (@danielroe)
- Ricardo Gobbo De Souza (@ricardogobbosouza)
- Rgehbt (@Gehbt)
v0.6.0
🚀 Enhancements
- Generate
runtime/
dts based on nuxttsconfig
options (#255) - Add builder versions to
module.json
(f8567a3) - Support transforming
jsx
(4841f2e)
🩹 Fixes
⚠️ Remove support for deprecatedRuntimeModuleHooks
interface (#228)- Add
-nightly
versions to externals (0a88a87) - Ignore exporting type if it is not defined (c308cc5)
- Mark
runtime/
directory as external (7a68e1e)
🏡 Chore
- Dedupe kit/schema/vue versions (aa0a710)
- Add root
dev:prepare
command (c308a68) - Migrate to eslint v9 (#250)
- Improve internal type safety and enable strict mode (78aa088)
- Tweak tsconfig settings (404aae7)
- Add more type annotations (ba0614b)
✅ Tests
- Update type testing step (#256)
- Add inline snapshots for
runtime/
transforms (#257) - Update snapshot (a39c183)
⚠️ Breaking Changes
⚠️ Remove support for deprecatedRuntimeModuleHooks
interface (#228)
❤️ Contributors
- Daniel Roe (@danielroe)