diff --git a/crates/swc/tests/fixture/issues-6xxx/6244/1/input/.swcrc b/crates/swc/tests/fixture/issues-6xxx/6244/1/input/.swcrc new file mode 100644 index 000000000000..9c7a2f1bfa8f --- /dev/null +++ b/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 +} \ No newline at end of file diff --git a/crates/swc/tests/fixture/issues-6xxx/6244/1/input/index.tsx b/crates/swc/tests/fixture/issues-6xxx/6244/1/input/index.tsx new file mode 100644 index 000000000000..9fa254551c78 --- /dev/null +++ b/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(, appContainer) \ No newline at end of file diff --git a/crates/swc/tests/fixture/issues-6xxx/6244/1/output/index.map b/crates/swc/tests/fixture/issues-6xxx/6244/1/output/index.map new file mode 100644 index 000000000000..733c63652ae1 --- /dev/null +++ b/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(, appContainer)" + ], + "version": 3 +} diff --git a/crates/swc/tests/fixture/issues-6xxx/6244/1/output/index.tsx b/crates/swc/tests/fixture/issues-6xxx/6244/1/output/index.tsx new file mode 100644 index 000000000000..9b71ea45593b --- /dev/null +++ b/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); diff --git a/node-swc/src/binding.js b/node-swc/src/binding.js index 3e92a348981b..6f1672839ef9 100644 --- a/node-swc/src/binding.js +++ b/node-swc/src/binding.js @@ -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 } @@ -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'))