-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix client build sourcemap generation (#4195)
- Loading branch information
Showing
10 changed files
with
100 additions
and
7 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Fix client build sourcemap generation |
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
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import react from '@astrojs/react'; | ||
|
||
export default defineConfig({ | ||
integrations: [react()], | ||
vite: { | ||
build: { | ||
sourcemap: true, | ||
} | ||
} | ||
}) |
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,11 @@ | ||
{ | ||
"name": "@test/sourcemap", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@astrojs/react": "workspace:*", | ||
"astro": "workspace:*", | ||
"react": "^18.1.0", | ||
"react-dom": "^18.1.0" | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/astro/test/fixtures/sourcemap/src/components/Counter.jsx
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,11 @@ | ||
import React, { useState } from 'react'; | ||
|
||
export default function Counter() { | ||
const [count, setCount] = useState(0); | ||
return ( | ||
<div> | ||
<div>Count: {count}</div> | ||
<button type="button" onClick={() => setCount(count+1)}>Increment</button> | ||
</div> | ||
); | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/astro/test/fixtures/sourcemap/src/pages/index.astro
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,17 @@ | ||
|
||
--- | ||
import Counter from '../components/Counter'; | ||
--- | ||
|
||
<html> | ||
|
||
<head> | ||
<title>Testing</title> | ||
</head> | ||
|
||
<body> | ||
<h1>Testing</h1> | ||
<Counter client:load /> | ||
</body> | ||
|
||
</html> |
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,22 @@ | ||
import { expect } from 'chai'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
describe('Sourcemap', async () => { | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ root: './fixtures/sourcemap/' }); | ||
await fixture.build(); | ||
}); | ||
|
||
it('Builds sourcemap', async () => { | ||
const dir = await fixture.readdir('.'); | ||
const counterMap = dir.find((file) => file.match(/^Counter\.\w+\.js\.map$/)); | ||
expect(counterMap).to.be.ok; | ||
}); | ||
|
||
it('Builds non-empty sourcemap', async () => { | ||
const map = await fixture.readFile('entry.mjs.map'); | ||
expect(map).to.not.include('"sources":[]'); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.