Getting started
Installation
Prerequisites
- Node.js version 18 or higher.
- A package manager: e.g. npm, pnpm, ...
sh
$ npm add -D @ogs-gmbh/rolldown-plugin-extensionssh
$ pnpm add -D @ogs-gmbh/rolldown-plugin-extensionssh
$ yarn add -D @ogs-gmbh/rolldown-plugin-extensionssh
$ bun add -D @ogs-gmbh/rolldown-plugin-extensionsUsage
rolldown-plugin-extensions can be integrated with either tsdown or Rolldown. Here's an example showing the usage of this plugin with tsdown. You can get a deeper understanding about this plugin by taking a look into the reference.
tsdown.config.ts
ts
import { defineConfig } from "tsdown";
import { extensionsPlugin } from "@ogs-gmbh/rolldown-plugin-extensions";
export default defineConfig({
entry: "src/**/*.ts",
dts: true,
outDir: "dist/main",
unbundle: true,
plugins: [
extensionsPlugin({
defaultExtensions: ".mjs",
extensions: {
".js": ".mjs",
".ts": ".mts"
}
})
]
});If a file gets referenced by any import or export statement, .mjs will be added to import targets, that doesn't include a extension. Files with .js and .ts extensions will be manipulated to have .mjs and .mts extensions instead.