Skip to content

Commit

Permalink
fix: sourcemap type error when build
Browse files Browse the repository at this point in the history
  • Loading branch information
chaxus committed Feb 4, 2024
1 parent 385f3d2 commit 16a1a4a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@
"/dist"
],
"dependencies": {
"magic-string": "^0.30.0"
"magic-string": "^0.30.6"
},
"devDependencies": {
"@types/node": "^18.16.1",
"@typescript-eslint/eslint-plugin": "^5.59.1",
"@typescript-eslint/parser": "^5.59.1",
"eslint": "^8.39.0",
"eslint-define-config": "^1.19.0",
"eslint-plugin-import": "^2.27.5",
"@types/node": "^20.11.16",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"eslint": "^8.56.0",
"eslint-define-config": "^2.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-regexp": "^1.14.0",
"eslint-plugin-regexp": "^2.2.0",
"prettier": "^2.8.8",
"typescript": "^5.0.4",
"vite": "^4.3.2",
"typescript": "^5.3.3",
"vite": "^5.0.12",
"vite-plugin-dts": "^2.3.0",
"vitest": "^0.30.1"
}
Expand Down
4 changes: 2 additions & 2 deletions src/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as MagicString from 'magic-string'
import type { SourceMap } from 'magic-string'
import type { Module } from '@/module'
import { Graph } from '@/graph'

Expand Down Expand Up @@ -30,9 +31,8 @@ export class Bundle {
}
/**
* @description: Code generation logic, splicing module AST node, output code
* @return {*}
*/
render(): { code: string; map: MagicString.SourceMap } {
render(): { code: string; map: Omit<SourceMap, 'sourcesContent'> & { sourcesContent: Array<string | null> }; } {
const msBundle = new MagicString.Bundle({ separator: '\n' })

this.graph.orderedModules.forEach((module) => {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Error = NodeJS.ErrnoException | null
interface Build {
generate: () => {
code: string
map: SourceMap
map: Omit<SourceMap, 'sourcesContent'> & { sourcesContent: Array<string | null> };
}
write: () => Promise<[WriteFileInfo, WriteFileInfo] | undefined>
}
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/jsx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ export const ranlexerJsxPlugin = () => {
type: '',
start: 0,
end: 0,
loc: {
start: {
index: 0, column: 0, line: 1
},
end: {
index: 0, column: 0, line: 1
}
}
}
},
generate(ast: Program): string {
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"isolatedModules": false,
"strict": true,
"noImplicitAny": true,
"skipLibCheck": true,
"useUnknownInCatchVariables": false,
"inlineSourceMap": true,
"baseUrl": ".",
Expand Down

0 comments on commit 16a1a4a

Please sign in to comment.