Browse Source

Merge pull request #705 from rollup/normalize-absolute

Add normalize-absolute test
ghi-672
Rich Harris 9 years ago
committed by GitHub
parent
commit
773ad3946f
  1. 2
      src/utils/defaults.js
  2. 14
      test/form/absolute-path-resolver/_config.js
  3. 10
      test/form/absolute-path-resolver/_expected/amd.js
  4. 8
      test/form/absolute-path-resolver/_expected/cjs.js
  5. 6
      test/form/absolute-path-resolver/_expected/es6.js
  6. 11
      test/form/absolute-path-resolver/_expected/iife.js
  7. 14
      test/form/absolute-path-resolver/_expected/umd.js
  8. 3
      test/form/absolute-path-resolver/a.js
  9. 4
      test/form/absolute-path-resolver/main.js

2
src/utils/defaults.js

@ -19,7 +19,7 @@ export function resolveId ( importee, importer ) {
if ( typeof process === 'undefined' ) throw new Error( `It looks like you're using Rollup in a non-Node.js environment. This means you must supply a plugin with custom resolveId and load functions. See https://github.com/rollup/rollup/wiki/Plugins for more information` );
// absolute paths are left untouched
if ( isAbsolute( importee ) ) return addJsExtensionIfNecessary( importee );
if ( isAbsolute( importee ) ) return addJsExtensionIfNecessary( resolve( importee ) );
// if this is the entry point, resolve against cwd
if ( importer === undefined ) return addJsExtensionIfNecessary( resolve( process.cwd(), importee ) );

14
test/form/absolute-path-resolver/_config.js

@ -0,0 +1,14 @@
var path = require('path');
module.exports = {
description: 'normalizes absolute ids',
options: {
plugins: [{
transform: function (code, id) {
if (/main/.test(id)) {
return code.replace('"./a.js"', JSON.stringify(path.resolve(__dirname, 'a.js')));
}
}
}]
}
};

10
test/form/absolute-path-resolver/_expected/amd.js

@ -0,0 +1,10 @@
define(function () { 'use strict';
var a = () => {
console.log('props');
};
a();
a();
});

8
test/form/absolute-path-resolver/_expected/cjs.js

@ -0,0 +1,8 @@
'use strict';
var a = () => {
console.log('props');
};
a();
a();

6
test/form/absolute-path-resolver/_expected/es6.js

@ -0,0 +1,6 @@
var a = () => {
console.log('props');
};
a();
a();

11
test/form/absolute-path-resolver/_expected/iife.js

@ -0,0 +1,11 @@
(function () {
'use strict';
var a = () => {
console.log('props');
};
a();
a();
}());

14
test/form/absolute-path-resolver/_expected/umd.js

@ -0,0 +1,14 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, function () { 'use strict';
var a = () => {
console.log('props');
};
a();
a();
}));

3
test/form/absolute-path-resolver/a.js

@ -0,0 +1,3 @@
export var a = () => {
console.log('props');
};

4
test/form/absolute-path-resolver/main.js

@ -0,0 +1,4 @@
import { a } from "./a.js";
import { a as b } from "./a.js";
a();
b();
Loading…
Cancel
Save