Skip to content

Commit

Permalink
Update magic-string and adjust types.
Browse files Browse the repository at this point in the history
The type of `sourcesContent` changed to allow for `null` elements, and
rollup needs to be adjusted to that as well.
  • Loading branch information
bmeurer committed Feb 13, 2023
1 parent 45d5d53 commit 28a68ec
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 14 deletions.
1 change: 1 addition & 0 deletions build-plugins/add-cli-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default function addCliEntry(): Plugin {
});
},
name: 'add-cli-entry',
//@ts-expect-error sourcesContent was changed to allow for null elements in recent versions of magic-string.
renderChunk(code, chunkInfo) {
if (chunkInfo.fileName === CLI_CHUNK) {
const magicString = new MagicString(code);
Expand Down
1 change: 1 addition & 0 deletions build-plugins/conditional-fsevents-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default function conditionalFsEventsImport(): Plugin {
}
},
name: 'conditional-fs-events-import',
//@ts-expect-error sourcesContent was changed to allow for null elements in recent versions of magic-string.
transform(code, id) {
if (id.endsWith('fsevents-handler.js')) {
transformed = true;
Expand Down
58 changes: 51 additions & 7 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 @@ -116,7 +116,7 @@
"is-reference": "^3.0.1",
"lint-staged": "^13.1.0",
"locate-character": "^2.0.5",
"magic-string": "^0.27.0",
"magic-string": "^0.29.0",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"pinia": "^2.0.29",
Expand Down
6 changes: 3 additions & 3 deletions src/rollup/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export interface ExistingDecodedSourceMap {
names: string[];
sourceRoot?: string;
sources: string[];
sourcesContent?: string[];
sourcesContent?: (string | null)[];
version: number;
}

Expand All @@ -62,7 +62,7 @@ export interface ExistingRawSourceMap {
names: string[];
sourceRoot?: string;
sources: string[];
sourcesContent?: string[];
sourcesContent?: (string | null)[];
version: number;
}

Expand All @@ -79,7 +79,7 @@ export interface SourceMap {
mappings: string;
names: string[];
sources: string[];
sourcesContent: string[];
sourcesContent: (string | null)[];
version: number;
toString(): string;
toUrl(): string;
Expand Down
6 changes: 3 additions & 3 deletions src/utils/collapseSourcemaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import { error, errorConflictingSourcemapSources, errorSourcemapBroken } from '.
import { basename, dirname, relative, resolve } from './path';

class Source {
readonly content: string;
readonly content: string | null;
readonly filename: string;
isOriginal = true;

constructor(filename: string, content: string) {
constructor(filename: string, content: string | null) {
this.filename = filename;
this.content = content;
}
Expand Down Expand Up @@ -48,7 +48,7 @@ class Link {
traceMappings() {
const sources: string[] = [];
const sourceIndexMap = new Map<string, number>();
const sourcesContent: string[] = [];
const sourcesContent: (string | null)[] = [];
const names: string[] = [];
const nameIndexMap = new Map<string, number>();

Expand Down

0 comments on commit 28a68ec

Please sign in to comment.