Skip to content

Commit 59add60

Browse files
authored
feat(node-resolve): expose plugin version (#1050)
1 parent 02fb349 commit 59add60

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

packages/node-resolve/src/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import builtinList from 'builtin-modules';
55
import deepMerge from 'deepmerge';
66
import isModule from 'is-module';
77

8+
import { version } from '../package.json';
9+
810
import { isDirCached, isFileCached, readCachedFile } from './cache';
911
import { fileExists, readFile, realpath } from './fs';
1012
import resolveImportSpecifiers from './resolveImportSpecifiers';
@@ -233,6 +235,8 @@ export function nodeResolve(opts = {}) {
233235
return {
234236
name: 'node-resolve',
235237

238+
version,
239+
236240
buildStart(options) {
237241
rollupOptions = options;
238242

packages/node-resolve/test/test.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ const failOnWarn = (t) => (warning) =>
1616

1717
const getLastPathFragment = (path) => path && path.split(/[\\/]/).slice(-1)[0];
1818

19+
test('exposes plugin version', (t) => {
20+
const plugin = nodeResolve();
21+
t.regex(plugin.version, /^\d+\.\d+\.\d+/);
22+
});
23+
1924
test('finds a module with jsnext:main', async (t) => {
2025
const bundle = await rollup({
2126
input: 'jsnext.js',
@@ -487,13 +492,13 @@ test('passes on "isEntry" flag', async (t) => {
487492
]
488493
});
489494
t.deepEqual(resolveOptions, [
490-
['other.js', 'main.js', { custom: void 0, isEntry: true }],
491-
['main.js', void 0, { custom: void 0, isEntry: true }],
492-
['dep.js', 'main.js', { custom: void 0, isEntry: false }]
495+
['other.js', 'main.js', { custom: {}, isEntry: true }],
496+
['main.js', void 0, { custom: {}, isEntry: true }],
497+
['dep.js', 'main.js', { custom: {}, isEntry: false }]
493498
]);
494499
});
495500

496-
test.only('passes on custom options', async (t) => {
501+
test('passes on custom options', async (t) => {
497502
const resolveOptions = [];
498503
await rollup({
499504
input: 'entry/other.js',

0 commit comments

Comments
 (0)