Skip to content

Commit

Permalink
feat(node-resolve): expose plugin version (#1050)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert authored Dec 13, 2021
1 parent 02fb349 commit 59add60
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/node-resolve/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import builtinList from 'builtin-modules';
import deepMerge from 'deepmerge';
import isModule from 'is-module';

import { version } from '../package.json';

import { isDirCached, isFileCached, readCachedFile } from './cache';
import { fileExists, readFile, realpath } from './fs';
import resolveImportSpecifiers from './resolveImportSpecifiers';
Expand Down Expand Up @@ -233,6 +235,8 @@ export function nodeResolve(opts = {}) {
return {
name: 'node-resolve',

version,

buildStart(options) {
rollupOptions = options;

Expand Down
13 changes: 9 additions & 4 deletions packages/node-resolve/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ const failOnWarn = (t) => (warning) =>

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

test('exposes plugin version', (t) => {
const plugin = nodeResolve();
t.regex(plugin.version, /^\d+\.\d+\.\d+/);
});

test('finds a module with jsnext:main', async (t) => {
const bundle = await rollup({
input: 'jsnext.js',
Expand Down Expand Up @@ -487,13 +492,13 @@ test('passes on "isEntry" flag', async (t) => {
]
});
t.deepEqual(resolveOptions, [
['other.js', 'main.js', { custom: void 0, isEntry: true }],
['main.js', void 0, { custom: void 0, isEntry: true }],
['dep.js', 'main.js', { custom: void 0, isEntry: false }]
['other.js', 'main.js', { custom: {}, isEntry: true }],
['main.js', void 0, { custom: {}, isEntry: true }],
['dep.js', 'main.js', { custom: {}, isEntry: false }]
]);
});

test.only('passes on custom options', async (t) => {
test('passes on custom options', async (t) => {
const resolveOptions = [];
await rollup({
input: 'entry/other.js',
Expand Down

0 comments on commit 59add60

Please sign in to comment.