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

Update magic-string and adjust types. #4846

Merged
merged 1 commit into from
Feb 14, 2023
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
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