@rollup/plugin-virtual
Advanced tools
Comparing version 2.0.3 to 2.1.0
# @rollup/plugin-virtual ChangeLog | ||
## v2.1.0 | ||
_2022-02-22_ | ||
### Features | ||
- feat: Move to Typescript (#578) | ||
### Updates | ||
- docs: Replace 'entry' with 'input' in readme (#1102) | ||
- chore: upgrade TypeScript (#716) | ||
- chore: update dependencies (236d7f1) | ||
## v2.0.3 | ||
@@ -4,0 +18,0 @@ |
@@ -1,39 +0,34 @@ | ||
import path from 'path'; | ||
import { resolve, dirname } from 'path'; | ||
/* eslint-disable consistent-return */ | ||
const PREFIX = `\0virtual:`; | ||
function virtual(modules) { | ||
const resolvedIds = new Map(); | ||
Object.keys(modules).forEach((id) => { | ||
resolvedIds.set(path.resolve(id), modules[id]); | ||
}); | ||
return { | ||
name: 'virtual', | ||
resolveId(id, importer) { | ||
if (id in modules) return PREFIX + id; | ||
if (importer) { | ||
// eslint-disable-next-line no-param-reassign | ||
if (importer.startsWith(PREFIX)) importer = importer.slice(PREFIX.length); | ||
const resolved = path.resolve(path.dirname(importer), id); | ||
if (resolvedIds.has(resolved)) return PREFIX + resolved; | ||
} | ||
}, | ||
load(id) { | ||
if (id.startsWith(PREFIX)) { | ||
// eslint-disable-next-line no-param-reassign | ||
id = id.slice(PREFIX.length); | ||
return id in modules ? modules[id] : resolvedIds.get(id); | ||
} | ||
} | ||
}; | ||
const resolvedIds = new Map(); | ||
Object.keys(modules).forEach((id) => { | ||
resolvedIds.set(resolve(id), modules[id]); | ||
}); | ||
return { | ||
name: 'virtual', | ||
resolveId(id, importer) { | ||
if (id in modules) | ||
return PREFIX + id; | ||
if (importer) { | ||
const importerNoPrefix = importer.startsWith(PREFIX) | ||
? importer.slice(PREFIX.length) | ||
: importer; | ||
const resolved = resolve(dirname(importerNoPrefix), id); | ||
if (resolvedIds.has(resolved)) | ||
return PREFIX + resolved; | ||
} | ||
return null; | ||
}, | ||
load(id) { | ||
if (id.startsWith(PREFIX)) { | ||
const idNoPrefix = id.slice(PREFIX.length); | ||
return idNoPrefix in modules ? modules[idNoPrefix] : resolvedIds.get(idNoPrefix); | ||
} | ||
return null; | ||
} | ||
}; | ||
} | ||
export default virtual; |
'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var path = require('path'); | ||
var path = _interopDefault(require('path')); | ||
/* eslint-disable consistent-return */ | ||
const PREFIX = `\0virtual:`; | ||
function virtual(modules) { | ||
const resolvedIds = new Map(); | ||
Object.keys(modules).forEach((id) => { | ||
resolvedIds.set(path.resolve(id), modules[id]); | ||
}); | ||
return { | ||
name: 'virtual', | ||
resolveId(id, importer) { | ||
if (id in modules) return PREFIX + id; | ||
if (importer) { | ||
// eslint-disable-next-line no-param-reassign | ||
if (importer.startsWith(PREFIX)) importer = importer.slice(PREFIX.length); | ||
const resolved = path.resolve(path.dirname(importer), id); | ||
if (resolvedIds.has(resolved)) return PREFIX + resolved; | ||
} | ||
}, | ||
load(id) { | ||
if (id.startsWith(PREFIX)) { | ||
// eslint-disable-next-line no-param-reassign | ||
id = id.slice(PREFIX.length); | ||
return id in modules ? modules[id] : resolvedIds.get(id); | ||
} | ||
} | ||
}; | ||
const resolvedIds = new Map(); | ||
Object.keys(modules).forEach((id) => { | ||
resolvedIds.set(path.resolve(id), modules[id]); | ||
}); | ||
return { | ||
name: 'virtual', | ||
resolveId(id, importer) { | ||
if (id in modules) | ||
return PREFIX + id; | ||
if (importer) { | ||
const importerNoPrefix = importer.startsWith(PREFIX) | ||
? importer.slice(PREFIX.length) | ||
: importer; | ||
const resolved = path.resolve(path.dirname(importerNoPrefix), id); | ||
if (resolvedIds.has(resolved)) | ||
return PREFIX + resolved; | ||
} | ||
return null; | ||
}, | ||
load(id) { | ||
if (id.startsWith(PREFIX)) { | ||
const idNoPrefix = id.slice(PREFIX.length); | ||
return idNoPrefix in modules ? modules[idNoPrefix] : resolvedIds.get(idNoPrefix); | ||
} | ||
return null; | ||
} | ||
}; | ||
} | ||
module.exports = virtual; |
{ | ||
"name": "@rollup/plugin-virtual", | ||
"version": "2.0.3", | ||
"version": "2.1.0", | ||
"publishConfig": { | ||
@@ -9,3 +9,6 @@ "access": "public" | ||
"license": "MIT", | ||
"repository": "rollup/plugins", | ||
"repository": { | ||
"url": "rollup/plugins", | ||
"directory": "packages/virtual" | ||
}, | ||
"author": "Rich Harris", | ||
@@ -15,20 +18,23 @@ "homepage": "https://github.com/rollup/plugins/tree/master/packages/virtual#readme", | ||
"main": "dist/index.js", | ||
"module": "dist/index.es.js", | ||
"engines": { | ||
"node": ">=8.0.0" | ||
}, | ||
"scripts": { | ||
"build": "rollup -c", | ||
"ci:coverage": "nyc pnpm run test && nyc report --reporter=text-lcov > coverage.lcov", | ||
"ci:lint": "pnpm run build && pnpm run lint", | ||
"ci:coverage": "nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov", | ||
"ci:lint": "pnpm build && pnpm lint", | ||
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}", | ||
"ci:test": "pnpm run test -- --verbose", | ||
"lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:package", | ||
"lint:docs": "prettier --single-quote --write README.md", | ||
"lint:js": "eslint --fix --cache src test --ext .js,.ts", | ||
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package", | ||
"ci:test": "pnpm test -- --verbose", | ||
"prebuild": "del-cli dist", | ||
"prepare": "pnpm run build", | ||
"prepublishOnly": "pnpm run lint", | ||
"pretest": "pnpm run build", | ||
"test": "ava" | ||
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi", | ||
"prerelease": "pnpm build", | ||
"pretest": "pnpm build", | ||
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name", | ||
"test": "ava", | ||
"test:ts": "tsc --noEmit" | ||
}, | ||
"files": [ | ||
"dist", | ||
"types", | ||
"README.md", | ||
@@ -49,6 +55,18 @@ "LICENSE" | ||
"devDependencies": { | ||
"@rollup/plugin-node-resolve": "^7.0.0", | ||
"rollup": "^2.0.0" | ||
"@rollup/plugin-node-resolve": "^8.4.0", | ||
"@rollup/plugin-typescript": "^6.0.0", | ||
"rollup": "^2.23.0", | ||
"typescript": "^4.1.2" | ||
}, | ||
"types": "types/index.d.ts", | ||
"ava": { | ||
"babel": { | ||
"compileEnhancements": false | ||
}, | ||
"extensions": [ | ||
"ts" | ||
], | ||
"require": [ | ||
"ts-node/register" | ||
], | ||
"files": [ | ||
@@ -60,4 +78,3 @@ "!**/fixtures/**", | ||
] | ||
}, | ||
"module": "dist/index.es.js" | ||
} | ||
} |
@@ -46,3 +46,3 @@ [npm]: https://img.shields.io/npm/v/@rollup/plugin-virtual | ||
export default { | ||
entry: 'src/entry.js', | ||
input: 'src/entry.js', | ||
// ... | ||
@@ -49,0 +49,0 @@ plugins: [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
73
7272
4