Comparing version 1.11.0 to 1.12.0
@@ -7,5 +7,3 @@ import * as _farmfe_core from '@farmfe/core'; | ||
export { Compiler as WebpackCompiler, WebpackPluginInstance } from 'webpack'; | ||
import * as _rolldown_node from '@rolldown/node'; | ||
import { Plugin as Plugin$2 } from '@rolldown/node'; | ||
export { Plugin as RolldownPlugin } from '@rolldown/node'; | ||
import * as rolldown_dist_types_plugin from 'rolldown/dist/types/plugin'; | ||
import * as vite from 'vite'; | ||
@@ -17,2 +15,4 @@ import { Plugin as Plugin$1 } from 'vite'; | ||
export { Plugin as RollupPlugin } from 'rollup'; | ||
import { Plugin as Plugin$2 } from 'rolldown'; | ||
export { Plugin as RolldownPlugin } from 'rolldown'; | ||
import * as esbuild from 'esbuild'; | ||
@@ -179,5 +179,4 @@ import { PluginBuild, OnLoadResult, Loader, BuildOptions, Plugin as Plugin$3 } from 'esbuild'; | ||
/** @experimental do not use it in production */ | ||
declare function createRolldownPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginFactoryOutput<UserOptions, Nested extends true ? _rolldown_node.Plugin[] : _rolldown_node.Plugin>; | ||
declare function createRolldownPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginFactoryOutput<UserOptions, Nested extends true ? rolldown_dist_types_plugin.Plugin<any>[] : rolldown_dist_types_plugin.Plugin<any>>; | ||
declare function createWebpackPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginFactoryOutput<UserOptions, webpack.WebpackPluginInstance>; | ||
/** @experimental do not use it in production */ | ||
declare function createRspackPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginFactoryOutput<UserOptions, _rspack_core_dist_config_zod.RspackPluginInstance>; | ||
@@ -184,0 +183,0 @@ declare function createFarmPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginFactoryOutput<UserOptions, _farmfe_core.JsPlugin>; |
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
@@ -20,10 +18,2 @@ var __export = (target, all) => { | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
@@ -39,7 +29,17 @@ | ||
// src/rspack/context.ts | ||
var import_path = require("path"); | ||
var import_buffer = require("buffer"); | ||
var import_webpack_sources = __toESM(require("webpack-sources")); | ||
var import_acorn = require("acorn"); | ||
function createBuildContext(compilation) { | ||
function contextOptionsFromCompilation(compilation) { | ||
return { | ||
addWatchFile(file) { | ||
compilation.fileDependencies.add(file); | ||
}, | ||
getWatchFiles() { | ||
return Array.from(compilation.fileDependencies); | ||
} | ||
}; | ||
} | ||
function createBuildContext(options, compilation) { | ||
return { | ||
parse(code, opts = {}) { | ||
@@ -53,3 +53,4 @@ return import_acorn.Parser.parse(code, { | ||
}, | ||
addWatchFile() { | ||
addWatchFile(id) { | ||
options.addWatchFile((0, import_path.resolve)(process.cwd(), id)); | ||
}, | ||
@@ -59,6 +60,6 @@ emitFile(emittedFile) { | ||
if (emittedFile.source && outFileName) { | ||
const { sources } = compilation.compiler.webpack; | ||
compilation.emitAsset( | ||
outFileName, | ||
new import_webpack_sources.default.RawSource( | ||
// @ts-expect-error types mismatch | ||
new sources.RawSource( | ||
typeof emittedFile.source === "string" ? emittedFile.source : import_buffer.Buffer.from(emittedFile.source) | ||
@@ -70,3 +71,3 @@ ) | ||
getWatchFiles() { | ||
return []; | ||
return options.getWatchFiles(); | ||
} | ||
@@ -91,6 +92,6 @@ }; | ||
// src/utils.ts | ||
var import_path = require("path"); | ||
var import_path2 = require("path"); | ||
function normalizeAbsolutePath(path) { | ||
if ((0, import_path.isAbsolute)(path)) | ||
return (0, import_path.normalize)(path); | ||
if ((0, import_path2.isAbsolute)(path)) | ||
return (0, import_path2.normalize)(path); | ||
else | ||
@@ -100,2 +101,10 @@ return path; | ||
// src/rspack/utils.ts | ||
function decodeVirtualModuleId(encoded, plugin) { | ||
return decodeURIComponent(encoded.slice(plugin.__virtualModulePrefix.length)); | ||
} | ||
function isVirtualModuleId(encoded, plugin) { | ||
return encoded.startsWith(plugin.__virtualModulePrefix); | ||
} | ||
// src/rspack/loaders/load.ts | ||
@@ -107,7 +116,7 @@ async function load(source, map) { | ||
const plugin = (_a = this._compiler) == null ? void 0 : _a.$unpluginContext[unpluginName]; | ||
const id = this.resource; | ||
let id = this.resource; | ||
if (!(plugin == null ? void 0 : plugin.load) || !id) | ||
return callback(null, source, map); | ||
if (plugin.loadInclude && !plugin.loadInclude(id)) | ||
return callback(null, source, map); | ||
if (isVirtualModuleId(id, plugin)) | ||
id = decodeVirtualModuleId(id, plugin); | ||
const context = createContext(this); | ||
@@ -117,3 +126,3 @@ const res = await plugin.load.call( | ||
{}, | ||
this._compilation && createBuildContext(this._compilation), | ||
this._compilation && createBuildContext(contextOptionsFromCompilation(this._compilation), this._compilation), | ||
context | ||
@@ -120,0 +129,0 @@ ), |
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
@@ -20,10 +18,2 @@ var __export = (target, all) => { | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
@@ -39,7 +29,17 @@ | ||
// src/rspack/context.ts | ||
var import_path = require("path"); | ||
var import_buffer = require("buffer"); | ||
var import_webpack_sources = __toESM(require("webpack-sources")); | ||
var import_acorn = require("acorn"); | ||
function createBuildContext(compilation) { | ||
function contextOptionsFromCompilation(compilation) { | ||
return { | ||
addWatchFile(file) { | ||
compilation.fileDependencies.add(file); | ||
}, | ||
getWatchFiles() { | ||
return Array.from(compilation.fileDependencies); | ||
} | ||
}; | ||
} | ||
function createBuildContext(options, compilation) { | ||
return { | ||
parse(code, opts = {}) { | ||
@@ -53,3 +53,4 @@ return import_acorn.Parser.parse(code, { | ||
}, | ||
addWatchFile() { | ||
addWatchFile(id) { | ||
options.addWatchFile((0, import_path.resolve)(process.cwd(), id)); | ||
}, | ||
@@ -59,6 +60,6 @@ emitFile(emittedFile) { | ||
if (emittedFile.source && outFileName) { | ||
const { sources } = compilation.compiler.webpack; | ||
compilation.emitAsset( | ||
outFileName, | ||
new import_webpack_sources.default.RawSource( | ||
// @ts-expect-error types mismatch | ||
new sources.RawSource( | ||
typeof emittedFile.source === "string" ? emittedFile.source : import_buffer.Buffer.from(emittedFile.source) | ||
@@ -70,3 +71,3 @@ ) | ||
getWatchFiles() { | ||
return []; | ||
return options.getWatchFiles(); | ||
} | ||
@@ -109,3 +110,3 @@ }; | ||
{}, | ||
this._compilation && createBuildContext(this._compilation), | ||
this._compilation && createBuildContext(contextOptionsFromCompilation(this._compilation), this._compilation), | ||
context | ||
@@ -120,4 +121,3 @@ ), | ||
callback(null, res.code, map == null ? map : res.map || map); | ||
else | ||
callback(null, res, map); | ||
else callback(null, res, map); | ||
} |
{ | ||
"name": "unplugin", | ||
"version": "1.11.0", | ||
"packageManager": "pnpm@8.15.7", | ||
"version": "1.12.0", | ||
"packageManager": "pnpm@8.15.9", | ||
"description": "Unified plugin system for build tools", | ||
@@ -45,36 +45,37 @@ "license": "MIT", | ||
"dependencies": { | ||
"acorn": "^8.11.3", | ||
"acorn": "^8.12.1", | ||
"chokidar": "^3.6.0", | ||
"webpack-sources": "^3.2.3", | ||
"webpack-virtual-modules": "^0.6.1" | ||
"webpack-virtual-modules": "^0.6.2" | ||
}, | ||
"devDependencies": { | ||
"@ampproject/remapping": "^2.3.0", | ||
"@antfu/eslint-config": "^2.13.3", | ||
"@antfu/ni": "^0.21.12", | ||
"@farmfe/cli": "^1.0.0", | ||
"@farmfe/core": "^1.0.19", | ||
"@rolldown/node": "^0.0.5", | ||
"@rspack/cli": "^0.6.1", | ||
"@rspack/core": "^0.6.1", | ||
"@antfu/eslint-config": "^2.23.2", | ||
"@antfu/ni": "^0.22.0", | ||
"@farmfe/cli": "^1.0.2", | ||
"@farmfe/core": "^1.3.9", | ||
"@rspack/cli": "1.0.0-alpha.5", | ||
"@rspack/core": "1.0.0-alpha.5", | ||
"@types/fs-extra": "^11.0.4", | ||
"@types/node": "^20.12.7", | ||
"@types/node": "^20.14.11", | ||
"@types/webpack-sources": "^3.2.3", | ||
"bumpp": "^9.4.0", | ||
"conventional-changelog-cli": "^4.1.0", | ||
"esbuild": "^0.20.2", | ||
"eslint": "^8.57.0", | ||
"bumpp": "^9.4.1", | ||
"conventional-changelog-cli": "^5.0.0", | ||
"esbuild": "^0.23.0", | ||
"esbuild-plugin-copy": "^2.1.1", | ||
"eslint": "^9.7.0", | ||
"fast-glob": "^3.3.2", | ||
"fs-extra": "^11.2.0", | ||
"jiti": "^1.21.0", | ||
"lint-staged": "^15.2.2", | ||
"magic-string": "^0.30.9", | ||
"picocolors": "^1.0.0", | ||
"rollup": "^4.14.2", | ||
"jiti": "^1.21.6", | ||
"lint-staged": "^15.2.7", | ||
"magic-string": "^0.30.10", | ||
"picocolors": "^1.0.1", | ||
"rolldown": "^0.12.2", | ||
"rollup": "^4.19.0", | ||
"simple-git-hooks": "^2.11.1", | ||
"tsup": "^8.0.2", | ||
"typescript": "^5.4.5", | ||
"vite": "^5.2.8", | ||
"vitest": "^1.5.0", | ||
"webpack": "^5.91.0", | ||
"tsup": "^8.2.2", | ||
"typescript": "^5.5.4", | ||
"vite": "^5.3.4", | ||
"vitest": "^2.0.4", | ||
"webpack": "^5.93.0", | ||
"webpack-cli": "4.10.0" | ||
@@ -81,0 +82,0 @@ }, |
@@ -15,3 +15,3 @@ # Unplugin | ||
- [esbuild](https://esbuild.github.io/) | ||
- [Rspack](https://www.rspack.dev/) (⚠️ experimental) | ||
- [Rspack](https://www.rspack.dev/) | ||
- [Rolldown](https://rolldown.rs/) (⚠️ experimental) | ||
@@ -18,0 +18,0 @@ - [Farm](https://www.farmfe.org/) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
186082
24
5175
30
9
Updatedacorn@^8.12.1