Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update bundle formats #17

Merged
merged 1 commit into from
Sep 24, 2024
Merged

feat: update bundle formats #17

merged 1 commit into from
Sep 24, 2024

Conversation

ivodolenc
Copy link
Member

Type of Change

  • New feature
  • Documentation
  • Breaking change

Breaking Changes

Changes default file formats for generated .js and .d.ts files .

Formats

During transformation, file formats are automatically resolved and in most cases there is no need for additional configuration.

Hyperbundler module environment for generated files defaults to esm, which means the outputs will have a .mjs extension unless otherwise specified. For TypeScript declarations, the appropriate extension will be .d.mts.

Formats can also be explicitly specified for each entry, if necessary.

Inputs

Default transformation behaviour for all chunk entries:

  • ./srcDir/file.js resolves to ./outDir/file.mjs
  • ./srcDir/file.mjs resolves to ./outDir/file.mjs
  • ./srcDir/file.cjs resolves to ./outDir/file.cjs
  • ./srcDir/file.ts resolves to ./outDir/file.mjs
  • ./srcDir/file.mts resolves to ./outDir/file.mjs
  • ./srcDir/file.cts resolves to ./outDir/file.cjs

Declarations

Default transformation behaviour for all dts entries:

  • ./srcDir/file.ts resolves to ./outDir/file.d.mts

Features

Adds dts alias for declaration entries.

Entry Declaration

Builds TypeScript declaration files (.d.ts) for production.

// bundler.config.ts

import { defineConfig } from '@hypernym/bundler'

export default defineConfig({
  entries: [
    { declaration: './src/types.ts' }, // => './dist/types.d.mts'
  ],
})

Also, it is possible to use dts alias.

import { defineConfig } from '@hypernym/bundler'

export default defineConfig({
  entries: [
    { dts: './src/types.ts' }, // => './dist/types.d.mts'
  ],
})

Other Changes

  • Improves types
  • Improves docs

@ivodolenc ivodolenc added breaking-change Breaking change docs Documentation feat New feature labels Sep 24, 2024
@ivodolenc ivodolenc merged commit 5a1b129 into main Sep 24, 2024
@ivodolenc ivodolenc deleted the feat/formats branch September 24, 2024 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Breaking change docs Documentation feat New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant