(isTsx: boolean)
| 203 | return { nonTsxOptions, tsxOptions }; |
| 204 | |
| 205 | function createVariant(isTsx: boolean): swcTypes.Options { |
| 206 | const swcOptions: swcTypes.Options = { |
| 207 | sourceMaps: sourceMap, |
| 208 | // isModule: true, |
| 209 | module: moduleType |
| 210 | ? { |
| 211 | type: moduleType, |
| 212 | ...(moduleType === 'amd' || moduleType === 'commonjs' || moduleType === 'umd' |
| 213 | ? { |
| 214 | noInterop: !esModuleInterop, |
| 215 | strictMode, |
| 216 | // For NodeNext and Node12, emit as CJS but do not transform dynamic imports |
| 217 | ignoreDynamic: nodeModuleEmitKind === 'nodecjs', |
| 218 | } |
| 219 | : {}), |
| 220 | } |
| 221 | : undefined, |
| 222 | swcrc: false, |
| 223 | jsc: { |
| 224 | externalHelpers: importHelpers, |
| 225 | parser: { |
| 226 | syntax: 'typescript', |
| 227 | tsx: isTsx, |
| 228 | decorators: experimentalDecorators, |
| 229 | dynamicImport: true, |
| 230 | importAssertions: true, |
| 231 | } as swcWasm.TsParserConfig, |
| 232 | target: swcTarget as swcWasm.JscTarget, |
| 233 | transform: { |
| 234 | decoratorMetadata: emitDecoratorMetadata, |
| 235 | legacyDecorator: true, |
| 236 | react: { |
| 237 | throwIfNamespace: false, |
| 238 | development: jsxDevelopment, |
| 239 | useBuiltins: false, |
| 240 | pragma: jsxFactory!, |
| 241 | pragmaFrag: jsxFragmentFactory!, |
| 242 | runtime: jsxRuntime, |
| 243 | importSource: jsxImportSource, |
| 244 | }, |
| 245 | useDefineForClassFields, |
| 246 | }, |
| 247 | keepClassNames, |
| 248 | experimental: { |
| 249 | keepImportAttributes: true, |
| 250 | emitAssertForImportAttributes: true, |
| 251 | } as swcTypes.JscConfig['experimental'], |
| 252 | }, |
| 253 | }; |
| 254 | |
| 255 | // Throw a helpful error if swc version is old, for example, if it rejects `ignoreDynamic` |
| 256 | try { |
| 257 | swcInstance.transformSync('', swcOptions); |
| 258 | } catch (e) { |
| 259 | throw new Error( |
| 260 | `${swcDepName} threw an error when attempting to validate swc compiler options.\n` + |
| 261 | 'You may be using an old version of swc which does not support the options used by ts-node.\n' + |
| 262 | 'Try upgrading to the latest version of swc.\n' + |
no outgoing calls
no test coverage detected
searching dependent graphs…