mirror of https://github.com/lukechilds/rollup.git
Rich-Harris
9 years ago
5 changed files with 37 additions and 2 deletions
@ -0,0 +1,28 @@ |
|||
const fs = require( 'fs' ); |
|||
const path = require( 'path' ); |
|||
const assert = require( 'assert' ); |
|||
|
|||
const HELPER = '\0helper'; |
|||
|
|||
module.exports = { |
|||
description: 'excludes plugin helpers from sources', |
|||
options: { |
|||
format: 'cjs', |
|||
plugins: [{ |
|||
resolveId ( id ) { |
|||
if ( id === HELPER ) return id; |
|||
}, |
|||
|
|||
load ( id ) { |
|||
if ( id === HELPER ) { |
|||
return fs.readFileSync( path.join( __dirname, 'helper.js' ), 'utf-8' ); |
|||
} |
|||
} |
|||
}] |
|||
}, |
|||
test: ( code, map ) => { |
|||
assert.equal( map.sources.length, 1 ); |
|||
assert.equal( map.sourcesContent.length, 1 ); |
|||
assert.ok( /main/.test( map.sources[0] ) ); |
|||
} |
|||
}; |
@ -0,0 +1,3 @@ |
|||
export default function foo ( input ) { |
|||
assert.equal( input, 42 ); |
|||
} |
@ -0,0 +1,3 @@ |
|||
import foo from '\0helper'; |
|||
|
|||
foo( 42 ); |
Loading…
Reference in new issue