diff --git a/packages/node-resolve/src/index.js b/packages/node-resolve/src/index.js index 8d6ee47b9..845a6dba9 100644 --- a/packages/node-resolve/src/index.js +++ b/packages/node-resolve/src/index.js @@ -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'; @@ -233,6 +235,8 @@ export function nodeResolve(opts = {}) { return { name: 'node-resolve', + version, + buildStart(options) { rollupOptions = options; diff --git a/packages/node-resolve/test/test.js b/packages/node-resolve/test/test.js index 3024aaff5..ece327f78 100755 --- a/packages/node-resolve/test/test.js +++ b/packages/node-resolve/test/test.js @@ -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', @@ -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',