UNPKG

unbundle

Version:

`require()` and `import`/`export` in the browser, without the bundling

36 lines (25 loc) 953 B
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.parse = undefined; var _path = require('path'); var _trimBefore = require('./trimBefore'); var _slash = require('slash'); var _slash2 = _interopRequireDefault(_slash); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var parse = exports.parse = function parse(file, output, destination) { return function (basedir, dependency, source, filename) { var result = (0, _path.relative)(basedir, dependency); if (result.includes('node_modules')) { var _context; var up = (0, _path.relative)((0, _path.dirname)(output), destination); var over = (_context = result, _trimBefore.trimBefore).call(_context, 'node_modules'); result = (0, _path.join)(up, over); } if (!result.startsWith('.')) { result = './' + result; } return (0, _slash2.default)(result); }; };