|
1 |
| -const { join, resolve } = require('path'); |
| 1 | +import { join, resolve } from 'path'; |
2 | 2 |
|
3 |
| -const test = require('ava'); |
4 |
| -const { rollup } = require('rollup'); |
5 |
| -const babel = require('rollup-plugin-babel'); |
6 |
| -const commonjs = require('rollup-plugin-commonjs'); |
| 3 | +import test from 'ava'; |
| 4 | +import { rollup } from 'rollup'; |
| 5 | +import babel from '@rollup/plugin-babel'; |
| 6 | +import commonjs from '@rollup/plugin-commonjs'; |
7 | 7 |
|
8 |
| -const { getCode, getImports, testBundle } = require('../../../util/test'); |
| 8 | +import { getCode, getImports, testBundle } from '../../../util/test'; |
9 | 9 |
|
10 |
| -const { nodeResolve } = require('..'); |
| 10 | +import { nodeResolve } from '..'; |
11 | 11 |
|
12 | 12 | process.chdir(join(__dirname, 'fixtures'));
|
13 | 13 |
|
@@ -51,6 +51,7 @@ test('finds a file inside a package directory', async (t) => {
|
51 | 51 | plugins: [
|
52 | 52 | nodeResolve(),
|
53 | 53 | babel({
|
| 54 | + babelHelpers: 'bundled', |
54 | 55 | presets: [
|
55 | 56 | [
|
56 | 57 | '@babel/preset-env',
|
@@ -104,6 +105,25 @@ test('supports non-standard extensions', async (t) => {
|
104 | 105 | await testBundle(t, bundle);
|
105 | 106 | });
|
106 | 107 |
|
| 108 | +test('supports JS extensions in TS when referring to TS imports', async (t) => { |
| 109 | + const bundle = await rollup({ |
| 110 | + input: 'ts-import-js-extension/import-ts-with-js-extension.ts', |
| 111 | + onwarn: () => t.fail('No warnings were expected'), |
| 112 | + plugins: [ |
| 113 | + nodeResolve({ |
| 114 | + extensions: ['.js', '.ts'] |
| 115 | + }), |
| 116 | + babel({ |
| 117 | + babelHelpers: 'bundled', |
| 118 | + plugins: ['@babel/plugin-transform-typescript'], |
| 119 | + extensions: ['.js', '.ts'] |
| 120 | + }) |
| 121 | + ] |
| 122 | + }); |
| 123 | + const { module } = await testBundle(t, bundle); |
| 124 | + t.is(module.exports, 'It works!'); |
| 125 | +}); |
| 126 | + |
107 | 127 | test('ignores IDs with null character', async (t) => {
|
108 | 128 | const result = await nodeResolve().resolveId('\0someid', 'test.js');
|
109 | 129 | t.is(result, null);
|
|
0 commit comments