Skip to content

Commit 0b72ed4

Browse files
committed
Use ESBuild to do more of the transpilation
1 parent be6e198 commit 0b72ed4

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*.log
33
node_modules
44
# Dist and query are both build output folders
5-
dist
5+
dist*/
66
!query/
77
# But don't ignore the RTK Query source
88
!src/query/

scripts/build.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ const entryPoints: EntryPointOptions[] = [
116116
]
117117

118118
const esVersionMappings = {
119+
// Don't output ES2015 - have TS convert to ES5 instead
120+
es2015: ts.ScriptTarget.ES5,
119121
es2017: ts.ScriptTarget.ES2017,
120122
es2018: ts.ScriptTarget.ES2018,
121123
es2019: ts.ScriptTarget.ES2019,
@@ -130,7 +132,7 @@ async function bundle(options: BuildOptions & EntryPointOptions) {
130132
folder = '',
131133
prefix = 'redux-toolkit',
132134
name,
133-
target,
135+
target = 'es2015',
134136
entryPoint,
135137
} = options
136138

@@ -142,7 +144,7 @@ async function bundle(options: BuildOptions & EntryPointOptions) {
142144
entryPoints: [entryPoint],
143145
outfile: outputFilePath,
144146
write: false,
145-
target: 'esnext',
147+
target: target,
146148
sourcemap: 'inline',
147149
bundle: true,
148150
format: format === 'umd' ? 'esm' : format,
@@ -232,7 +234,11 @@ async function bundle(options: BuildOptions & EntryPointOptions) {
232234
mapping = transformResult.map as RawSourceMap
233235
}
234236

235-
console.log('Build artifact:', chunk.path)
237+
const relativePath = path.relative(process.cwd(), chunk.path)
238+
console.log(`Build artifact: ${relativePath}, settings: `, {
239+
target,
240+
output: ts.ScriptTarget[esVersion],
241+
})
236242
await fs.writeFile(chunk.path, code)
237243
await fs.writeJSON(chunk.path + '.map', mapping)
238244
}

0 commit comments

Comments
 (0)