-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #514 from xmtp/rygine/rollup
Replace `tsup` with `rollup`
- Loading branch information
Showing
17 changed files
with
3,031 additions
and
794 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
*.config.js | ||
*.config.ts | ||
*.test.js | ||
*.test.ts | ||
dist | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ dist | |
coverage | ||
docs | ||
tmp | ||
build/rollup-plugin-resolve-extensions/index.js |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { basename, dirname, extname, format } from 'node:path' | ||
import { existsSync } from 'node:fs' | ||
import { Plugin } from 'rollup' | ||
import { getResolvedPath, loadCompilerOptions } from '../utils' | ||
|
||
export const resolveExtensions = ( | ||
extensions: string[] = [], | ||
tsconfigPath?: string | ||
): Plugin => { | ||
const compilerOptions = loadCompilerOptions(tsconfigPath) | ||
return { | ||
name: 'resolve-extensions', | ||
async resolveId(source, importer, options) { | ||
if (extensions.length && !options.isEntry && importer) { | ||
const resolvedPath = getResolvedPath(source, importer, compilerOptions) | ||
let updatedSource = '' | ||
|
||
if (resolvedPath) { | ||
const ext = extname(resolvedPath) | ||
const base = basename(resolvedPath, ext) | ||
const dir = dirname(resolvedPath) | ||
// check for extensions | ||
extensions.some((extension) => { | ||
const newPath = format({ | ||
dir, | ||
name: base, | ||
ext: `${extension}${ext}`, | ||
}) | ||
const exists = existsSync(newPath) | ||
if (exists) { | ||
updatedSource = newPath | ||
return true | ||
} | ||
return false | ||
}) | ||
|
||
return updatedSource || null | ||
} | ||
} | ||
return null | ||
}, | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.