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

chore(deps-dev): bump @types/node from 20.14.11 to 22.0.0 #55

Merged
merged 3 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/auto-merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
id: metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
github-token: '${{ secrets.GITHUB_TOKEN }}'
- name: Approve a PR
run: gh pr review --approve "$PR_URL"
env:
Expand Down
169 changes: 74 additions & 95 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@changesets/cli": "2.27.7",
"@rollup/plugin-typescript": "11.1.6",
"@types/jest": "^29.5.12",
"@types/node": "20.14.11",
"@types/node": "22.0.0",
"@typescript-eslint/eslint-plugin": "7.18.0",
"@typescript-eslint/parser": "7.17.0",
"eslint": "^8.0.0",
Expand Down
15 changes: 7 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import pluginUtils from '@rollup/pluginutils';
import fs from 'fs';
import { ExistingRawSourceMap, Plugin } from 'rollup';
import { ExistingRawSourceMap, Plugin, PluginContext } from 'rollup';
import { promisify } from 'util';
import { resolveSourceMap, resolveSources } from './source-map-resolve';
import { SourcemapsPluginOptions } from './types';

const { createFilter } = pluginUtils;

export default function sourcemaps({
include,
exclude,
readFile = fs.readFile,
}: SourcemapsPluginOptions = {}): Plugin {
export default function sourcemaps(
// eslint-disable-next-line @typescript-eslint/unbound-method
{ include, exclude, readFile = fs.readFile }: SourcemapsPluginOptions = {},
): Plugin {
// Create a filter function based on the include and exclude options
const filter = createFilter(include, exclude);

Expand All @@ -21,7 +20,7 @@ export default function sourcemaps({
return {
name: 'sourcemaps',

async load(id: string) {
load: async function (this: PluginContext, id: string) {
let code: string;
// If the id does not pass the filter, return null
if (!filter(id)) {
Expand Down Expand Up @@ -66,7 +65,7 @@ export default function sourcemaps({
const { sourcesContent } = await resolveSources(map, id, promisifiedReadFile);
// If all sources are strings, assign them to map.sourcesContent
if (sourcesContent.every(item => typeof item === 'string')) {
map.sourcesContent = sourcesContent as string[];
map.sourcesContent = sourcesContent;
}
} catch {
// If resolving the sources fails, warn
Expand Down