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

test(es): Add a test for a fixed source map issue #6768

Merged
merged 6 commits into from
Jan 9, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions crates/swc/tests/fixture/issues-6xxx/6244/1/input/.swcrc
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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