|
1 | 1 | import { assert, describe, expect, test } from 'vitest' |
2 | 2 | import babelPlugin from './index.ts' |
3 | | -import * as babel from '@babel/core' |
| 3 | +import * as babel from './babelCompat.ts' |
4 | 4 | import { rolldown, type OutputChunk } from 'rolldown' |
5 | 5 | import { build as viteBuild, createBuilder, type Rollup } from 'vite' |
6 | 6 | import path from 'node:path' |
7 | 7 | import { collectOptimizeDepsInclude, type PluginOptions } from './options.ts' |
8 | 8 | import type { RolldownBabelPreset } from './rolldownPreset.ts' |
| 9 | +import { stripVTControlCharacters } from 'node:util' |
9 | 10 |
|
10 | 11 | test('plugin works', async () => { |
11 | 12 | const result = await build('foo.js', 'export const result = foo', { |
@@ -226,7 +227,7 @@ test('wrapPluginVisitorMethod wraps visitor calls', async () => { |
226 | 227 | const result = await build('foo.js', 'export const result = foo', { |
227 | 228 | plugins: [identifierReplaceBabelPlugin('foo', true)], |
228 | 229 | wrapPluginVisitorMethod(_pluginAlias, _visitorType, callback) { |
229 | | - return function (this, p, state) { |
| 230 | + return function (this: any, p, state) { |
230 | 231 | wrapCalled = true |
231 | 232 | return callback.call(this, p, state) |
232 | 233 | } |
@@ -553,7 +554,7 @@ test('babel syntax error produces enhanced error message', async () => { |
553 | 554 | const err = await build('foo.js', 'export const = ;', { |
554 | 555 | plugins: [identifierReplaceBabelPlugin('foo', true)], |
555 | 556 | }).catch((e) => e) |
556 | | - const normalized = err.message |
| 557 | + const normalized = stripVTControlCharacters(err.message) |
557 | 558 | .replace(/\r\n/g, '\n') |
558 | 559 | .replace(/(?:[A-Z]:)?[\\/][^\s:]+[\\/](?=foo\.js)/gi, '<cwd>/') |
559 | 560 | .replace(/\n {4,}at .+/g, '') |
|
0 commit comments