Skip to content

Commit e7be4fc

Browse files
committed
feat: less babel, more eslint in Hermes pipeline
1 parent 7b03297 commit e7be4fc

3 files changed

Lines changed: 29 additions & 117 deletions

File tree

bundler/bundle.js

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -110,38 +110,42 @@ export const init = async ({ platform, jest, flow, target, jestConfig, outdir, e
110110
if (options.platform === 'hermes') {
111111
const babel = await import('./babel-worker.cjs')
112112
loadPipeline.push(async (source, filepath) => {
113-
if (source.includes('using ')) {
114-
try {
115-
const res = await esbuild.transform(source, {
116-
sourcemap: 'inline',
117-
sourcefile: filepath,
118-
supported: {
119-
using: false,
120-
},
121-
})
122-
if (res.warnings.length > 0) {
123-
console.log(...(await formatMessages(res.warnings, 'warning')))
124-
}
125-
126-
source = res.code
127-
} catch (e) {
128-
console.log(...(await formatMessages(e.errors, 'error')))
129-
throw new Error('Transform failed', { cause: e })
113+
const loader = extname(filepath).replace(/^\.[cm]?/, '')
114+
assert(['js', 'ts', 'jsx', 'tsx'].includes(loader))
115+
try {
116+
const res = await esbuild.transform(source, {
117+
sourcemap: 'inline',
118+
sourcefile: filepath,
119+
loader,
120+
supported: {
121+
'class-private-accessor': false,
122+
'class-private-brand-check': false,
123+
'class-private-field': false,
124+
'class-private-method': false,
125+
'class-private-static-accessor': false,
126+
'class-private-static-field': false,
127+
'class-private-static-method': false,
128+
'class-static-blocks': false,
129+
'class-static-field': false,
130+
'import-attributes': false,
131+
using: false,
132+
},
133+
})
134+
if (res.warnings.length > 0) {
135+
console.log(...(await formatMessages(res.warnings, 'warning')))
130136
}
137+
138+
source = res.code
139+
} catch (e) {
140+
console.log(...(await formatMessages(e.errors, 'error')))
141+
throw new Error('Transform failed', { cause: e })
131142
}
132143

133144
const result = await babel.transformAsync(source, {
134145
compact: false,
135146
babelrc: false,
136147
configFile: false,
137-
plugins: [
138-
'@babel/plugin-syntax-typescript',
139-
'@babel/plugin-syntax-import-attributes',
140-
'@babel/plugin-transform-block-scoping',
141-
'@babel/plugin-transform-class-properties',
142-
'@babel/plugin-transform-classes',
143-
'@babel/plugin-transform-private-methods',
144-
],
148+
plugins: ['@babel/plugin-transform-block-scoping', '@babel/plugin-transform-classes'],
145149
})
146150
return result.code
147151
})

bundler/package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,8 @@
7373
},
7474
"optionalDependencies": {
7575
"@babel/core": "^7.0.0",
76-
"@babel/plugin-syntax-import-attributes": "^7.0.0",
77-
"@babel/plugin-syntax-typescript": "^7.0.0",
7876
"@babel/plugin-transform-block-scoping": "^7.0.0",
79-
"@babel/plugin-transform-class-properties": "^7.0.0",
8077
"@babel/plugin-transform-classes": "^7.0.0",
81-
"@babel/plugin-transform-private-methods": "^7.0.0",
8278
"flow-remove-types": "^2.242.0"
8379
},
8480
"peerDependencies": {

pnpm-lock.yaml

Lines changed: 0 additions & 88 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)