Browse Source

fix super-niche resolution bug affecting online demo

better-aggressive
Rich-Harris 9 years ago
parent
commit
35cabd7621
  1. 5
      src/Module.js
  2. 15
      test/function/export-default-anonymous-function/_config.js
  3. 1
      test/function/export-default-anonymous-function/answer.js
  4. 5
      test/function/export-default-anonymous-function/main.js

5
src/Module.js

@ -281,7 +281,10 @@ export default class Module {
}
basename () {
return makeLegalIdentifier( basename( this.id ).slice( 0, -extname( this.id ).length ) );
const base = basename( this.id );
const ext = extname( this.id );
return makeLegalIdentifier( ext ? base.slice( 0, -ext.length ) : base );
}
bindAliases () {

15
test/function/export-default-anonymous-function/_config.js

@ -0,0 +1,15 @@
var fs = require( 'fs' );
var path = require( 'path' );
module.exports = {
description: 'exports an anonymous function with custom ID resolver', // yeah, this is a real edge case
options: {
resolveId: function ( importee, importer ) {
return path.basename( importee ).replace( /\..+/, '' );
},
load: function ( id ) {
console.log( 'id', id )
return fs.readFileSync( path.join( __dirname, id + '.js' ), 'utf-8' );
}
}
};

1
test/function/export-default-anonymous-function/answer.js

@ -0,0 +1 @@
export default 42;

5
test/function/export-default-anonymous-function/main.js

@ -0,0 +1,5 @@
import answer from './answer';
export default function () {
console.log( 'the answer is ' + answer );
}
Loading…
Cancel
Save