Skip to content

Commit

Permalink
test(es): Add a test for a fixed source map issue (#6768)
Browse files Browse the repository at this point in the history
**Related issue:**

 - Closes #6244.
  • Loading branch information
kdy1 committed Jan 9, 2023
1 parent a225efe commit 6c126da
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
19 changes: 19 additions & 0 deletions crates/swc/tests/fixture/issues-6xxx/6244/1/input/.swcrc
@@ -0,0 +1,19 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"target": "es2020",
"parser": {
"syntax": "typescript",
"tsx": true
},
"transform": {
"react": {
"runtime": "automatic",
"useBuiltins": true
}
}
},
"sourceMaps": true,
"inlineSourcesContent": true,
"minify": false
}
6 changes: 6 additions & 0 deletions crates/swc/tests/fixture/issues-6xxx/6244/1/input/index.tsx
@@ -0,0 +1,6 @@
import {render} from 'react-dom'
import {App} from './app'

const appContainer = document.getElementById('project-root')

render(<App />, appContainer)
17 changes: 17 additions & 0 deletions crates/swc/tests/fixture/issues-6xxx/6244/1/output/index.map
@@ -0,0 +1,17 @@
{
"mappings": "AAAA;AAAA,SAAQA,MAAM,QAAO,YAAW;AAChC,SAAQC,GAAG,QAAO,QAAO;AAEzB,MAAMC,eAAeC,SAASC,cAAc,CAAC;AAE7CJ,qBAAO,KAACC,UAAQC",
"names": [
"render",
"App",
"appContainer",
"document",
"getElementById"
],
"sources": [
"../../input/index.tsx"
],
"sourcesContent": [
"import {render} from 'react-dom'\nimport {App} from './app'\n\nconst appContainer = document.getElementById('project-root')\n\nrender(<App />, appContainer)"
],
"version": 3
}
5 changes: 5 additions & 0 deletions crates/swc/tests/fixture/issues-6xxx/6244/1/output/index.tsx
@@ -0,0 +1,5 @@
import { jsx as _jsx } from "react/jsx-runtime";
import { render } from 'react-dom';
import { App } from './app';
const appContainer = document.getElementById('project-root');
render(/*#__PURE__*/ _jsx(App, {}), appContainer);
12 changes: 11 additions & 1 deletion node-swc/src/binding.js
Expand Up @@ -11,7 +11,8 @@ function isMusl() {
// For Node 10
if (!process.report || typeof process.report.getReport !== 'function') {
try {
return readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
const lddPath = require('child_process').execSync('which ldd').toString().trim();
return readFileSync(lddPath, 'utf8').includes('musl')
} catch (e) {
return true
}
Expand Down Expand Up @@ -101,6 +102,15 @@ switch (platform) {
}
break
case 'darwin':
localFileExisted = existsSync(join(__dirname, 'swc.darwin-universal.node'))
try {
if (localFileExisted) {
nativeBinding = require('./swc.darwin-universal.node')
} else {
nativeBinding = require('@swc/core-darwin-universal')
}
break
} catch {}
switch (arch) {
case 'x64':
localFileExisted = existsSync(join(__dirname, 'swc.darwin-x64.node'))
Expand Down

0 comments on commit 6c126da

Please sign in to comment.