@plumeria/unplugin 18.1.3 → 18.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bun.d.ts +1 -1
- package/dist/bun.js +21 -1
- package/dist/bun.mjs +21 -1
- package/dist/core.js +3 -6
- package/dist/core.mjs +3 -6
- package/dist/css-marker.d.ts +2 -0
- package/dist/css-marker.js +87 -0
- package/dist/css-marker.mjs +50 -0
- package/dist/esbuild.js +55 -1
- package/dist/esbuild.mjs +22 -1
- package/dist/index.d.ts +1 -1
- package/package.json +2 -2
package/dist/bun.d.ts
CHANGED
package/dist/bun.js
CHANGED
|
@@ -2,4 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const unplugin_1 = require("unplugin");
|
|
4
4
|
const core_1 = require("./core");
|
|
5
|
-
|
|
5
|
+
const css_marker_1 = require("./css-marker");
|
|
6
|
+
const createPlugin = (outputs) => (0, unplugin_1.createBunPlugin)((options, metaOptions) => ({
|
|
7
|
+
...(0, core_1.unpluginFactory)(options, metaOptions),
|
|
8
|
+
writeBundle() {
|
|
9
|
+
(0, css_marker_1.stripCssMarkersIn)(outputs);
|
|
10
|
+
},
|
|
11
|
+
}));
|
|
12
|
+
exports.default = (options) => {
|
|
13
|
+
const outputs = new Set();
|
|
14
|
+
const plugin = createPlugin(outputs)(options);
|
|
15
|
+
const setup = plugin.setup;
|
|
16
|
+
return {
|
|
17
|
+
...plugin,
|
|
18
|
+
async setup(build) {
|
|
19
|
+
const outdir = build?.config?.outdir;
|
|
20
|
+
if (outdir)
|
|
21
|
+
outputs.add(outdir);
|
|
22
|
+
return setup.call(plugin, build);
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
};
|
package/dist/bun.mjs
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
1
|
import { createBunPlugin } from 'unplugin';
|
|
2
2
|
import { unpluginFactory } from './core.mjs';
|
|
3
|
-
|
|
3
|
+
import { stripCssMarkersIn } from './css-marker.mjs';
|
|
4
|
+
const createPlugin = (outputs) => createBunPlugin((options, metaOptions) => ({
|
|
5
|
+
...unpluginFactory(options, metaOptions),
|
|
6
|
+
writeBundle() {
|
|
7
|
+
stripCssMarkersIn(outputs);
|
|
8
|
+
},
|
|
9
|
+
}));
|
|
10
|
+
export default (options) => {
|
|
11
|
+
const outputs = new Set();
|
|
12
|
+
const plugin = createPlugin(outputs)(options);
|
|
13
|
+
const setup = plugin.setup;
|
|
14
|
+
return {
|
|
15
|
+
...plugin,
|
|
16
|
+
async setup(build) {
|
|
17
|
+
const outdir = build?.config?.outdir;
|
|
18
|
+
if (outdir)
|
|
19
|
+
outputs.add(outdir);
|
|
20
|
+
return setup.call(plugin, build);
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
};
|
package/dist/core.js
CHANGED
|
@@ -70,11 +70,7 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
70
70
|
const [pathId, query] = id.split('?');
|
|
71
71
|
if (pathId.endsWith('.zero.css')) {
|
|
72
72
|
if (pathId.startsWith('/')) {
|
|
73
|
-
|
|
74
|
-
if (!absolutePath) {
|
|
75
|
-
absolutePath = path.join(viteRoot, pathId);
|
|
76
|
-
}
|
|
77
|
-
return query ? `${absolutePath}?${query}` : absolutePath;
|
|
73
|
+
return id;
|
|
78
74
|
}
|
|
79
75
|
if (importer && !path.isAbsolute(pathId)) {
|
|
80
76
|
const resolved = path.resolve(path.dirname(importer), pathId);
|
|
@@ -90,7 +86,8 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
90
86
|
},
|
|
91
87
|
load(id) {
|
|
92
88
|
const [pathId] = id.split('?', 1);
|
|
93
|
-
|
|
89
|
+
const resolved = cssFileLookup.get(pathId) ?? path.join(viteRoot, pathId);
|
|
90
|
+
return cssLookup.get(resolved) ?? cssLookup.get(pathId) ?? '';
|
|
94
91
|
},
|
|
95
92
|
transformInclude(id) {
|
|
96
93
|
return filter(id);
|
package/dist/core.mjs
CHANGED
|
@@ -34,11 +34,7 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
34
34
|
const [pathId, query] = id.split('?');
|
|
35
35
|
if (pathId.endsWith('.zero.css')) {
|
|
36
36
|
if (pathId.startsWith('/')) {
|
|
37
|
-
|
|
38
|
-
if (!absolutePath) {
|
|
39
|
-
absolutePath = path.join(viteRoot, pathId);
|
|
40
|
-
}
|
|
41
|
-
return query ? `${absolutePath}?${query}` : absolutePath;
|
|
37
|
+
return id;
|
|
42
38
|
}
|
|
43
39
|
if (importer && !path.isAbsolute(pathId)) {
|
|
44
40
|
const resolved = path.resolve(path.dirname(importer), pathId);
|
|
@@ -54,7 +50,8 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
54
50
|
},
|
|
55
51
|
load(id) {
|
|
56
52
|
const [pathId] = id.split('?', 1);
|
|
57
|
-
|
|
53
|
+
const resolved = cssFileLookup.get(pathId) ?? path.join(viteRoot, pathId);
|
|
54
|
+
return cssLookup.get(resolved) ?? cssLookup.get(pathId) ?? '';
|
|
58
55
|
},
|
|
59
56
|
transformInclude(id) {
|
|
60
57
|
return filter(id);
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.stripCssMarkers = stripCssMarkers;
|
|
37
|
+
exports.stripCssMarkersIn = stripCssMarkersIn;
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const COMMENT = /\/\*[\s\S]*?\*\//g;
|
|
41
|
+
function stripCssMarkers(css) {
|
|
42
|
+
return css
|
|
43
|
+
.replace(COMMENT, (comment) => comment.includes('.zero.css') ? '' : comment)
|
|
44
|
+
.replace(/^\s*\n/, '')
|
|
45
|
+
.replace(/\n{3,}/g, '\n\n');
|
|
46
|
+
}
|
|
47
|
+
function collectCssFiles(target, found) {
|
|
48
|
+
let stat;
|
|
49
|
+
try {
|
|
50
|
+
stat = fs.statSync(target);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (stat.isFile()) {
|
|
56
|
+
if (target.endsWith('.css'))
|
|
57
|
+
found.push(target);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (!stat.isDirectory())
|
|
61
|
+
return;
|
|
62
|
+
for (const entry of fs.readdirSync(target)) {
|
|
63
|
+
collectCssFiles(path.join(target, entry), found);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function stripCssMarkersIn(targets) {
|
|
67
|
+
const found = [];
|
|
68
|
+
for (const target of targets) {
|
|
69
|
+
if (!target)
|
|
70
|
+
continue;
|
|
71
|
+
collectCssFiles(path.resolve(target), found);
|
|
72
|
+
}
|
|
73
|
+
for (const file of new Set(found)) {
|
|
74
|
+
let css;
|
|
75
|
+
try {
|
|
76
|
+
css = fs.readFileSync(file, 'utf-8');
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (!css.includes('.zero.css'))
|
|
82
|
+
continue;
|
|
83
|
+
const stripped = stripCssMarkers(css);
|
|
84
|
+
if (stripped !== css)
|
|
85
|
+
fs.writeFileSync(file, stripped, 'utf-8');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
const COMMENT = /\/\*[\s\S]*?\*\//g;
|
|
4
|
+
export function stripCssMarkers(css) {
|
|
5
|
+
return css
|
|
6
|
+
.replace(COMMENT, (comment) => comment.includes('.zero.css') ? '' : comment)
|
|
7
|
+
.replace(/^\s*\n/, '')
|
|
8
|
+
.replace(/\n{3,}/g, '\n\n');
|
|
9
|
+
}
|
|
10
|
+
function collectCssFiles(target, found) {
|
|
11
|
+
let stat;
|
|
12
|
+
try {
|
|
13
|
+
stat = fs.statSync(target);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (stat.isFile()) {
|
|
19
|
+
if (target.endsWith('.css'))
|
|
20
|
+
found.push(target);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (!stat.isDirectory())
|
|
24
|
+
return;
|
|
25
|
+
for (const entry of fs.readdirSync(target)) {
|
|
26
|
+
collectCssFiles(path.join(target, entry), found);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function stripCssMarkersIn(targets) {
|
|
30
|
+
const found = [];
|
|
31
|
+
for (const target of targets) {
|
|
32
|
+
if (!target)
|
|
33
|
+
continue;
|
|
34
|
+
collectCssFiles(path.resolve(target), found);
|
|
35
|
+
}
|
|
36
|
+
for (const file of new Set(found)) {
|
|
37
|
+
let css;
|
|
38
|
+
try {
|
|
39
|
+
css = fs.readFileSync(file, 'utf-8');
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (!css.includes('.zero.css'))
|
|
45
|
+
continue;
|
|
46
|
+
const stripped = stripCssMarkers(css);
|
|
47
|
+
if (stripped !== css)
|
|
48
|
+
fs.writeFileSync(file, stripped, 'utf-8');
|
|
49
|
+
}
|
|
50
|
+
}
|
package/dist/esbuild.js
CHANGED
|
@@ -1,5 +1,59 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
const unplugin_1 = require("unplugin");
|
|
37
|
+
const path = __importStar(require("path"));
|
|
4
38
|
const core_1 = require("./core");
|
|
5
|
-
|
|
39
|
+
const css_marker_1 = require("./css-marker");
|
|
40
|
+
function attachEsbuildHooks(plugin) {
|
|
41
|
+
const outputs = new Set();
|
|
42
|
+
return {
|
|
43
|
+
...plugin,
|
|
44
|
+
esbuild: {
|
|
45
|
+
...plugin.esbuild,
|
|
46
|
+
config(options) {
|
|
47
|
+
plugin.esbuild?.config?.call(this, options);
|
|
48
|
+
if (options.outdir)
|
|
49
|
+
outputs.add(options.outdir);
|
|
50
|
+
if (options.outfile)
|
|
51
|
+
outputs.add(path.dirname(options.outfile));
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
writeBundle() {
|
|
55
|
+
(0, css_marker_1.stripCssMarkersIn)(outputs);
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
exports.default = (0, unplugin_1.createEsbuildPlugin)((options, metaOptions) => attachEsbuildHooks((0, core_1.unpluginFactory)(options, metaOptions)));
|
package/dist/esbuild.mjs
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
1
|
import { createEsbuildPlugin } from 'unplugin';
|
|
2
|
+
import * as path from 'path';
|
|
2
3
|
import { unpluginFactory } from './core.mjs';
|
|
3
|
-
|
|
4
|
+
import { stripCssMarkersIn } from './css-marker.mjs';
|
|
5
|
+
function attachEsbuildHooks(plugin) {
|
|
6
|
+
const outputs = new Set();
|
|
7
|
+
return {
|
|
8
|
+
...plugin,
|
|
9
|
+
esbuild: {
|
|
10
|
+
...plugin.esbuild,
|
|
11
|
+
config(options) {
|
|
12
|
+
plugin.esbuild?.config?.call(this, options);
|
|
13
|
+
if (options.outdir)
|
|
14
|
+
outputs.add(options.outdir);
|
|
15
|
+
if (options.outfile)
|
|
16
|
+
outputs.add(path.dirname(options.outfile));
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
writeBundle() {
|
|
20
|
+
stripCssMarkersIn(outputs);
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export default createEsbuildPlugin((options, metaOptions) => attachEsbuildHooks(unpluginFactory(options, metaOptions)));
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import vite from './vite';
|
|
|
8
8
|
import webpack from './webpack';
|
|
9
9
|
import unloader from './unloader';
|
|
10
10
|
declare const plumeria: {
|
|
11
|
-
bun: (options?: import("./core").PluginOptions
|
|
11
|
+
bun: (options?: import("./core").PluginOptions) => any;
|
|
12
12
|
esbuild: (options?: import("./core").PluginOptions | undefined) => import("unplugin").EsbuildPlugin;
|
|
13
13
|
farm: (options?: import("./core").PluginOptions) => any;
|
|
14
14
|
rolldown: (options?: import("./core").PluginOptions | undefined) => import("unplugin").RolldownPlugin<any> | import("unplugin").RolldownPlugin<any>[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/unplugin",
|
|
3
|
-
"version": "18.1.
|
|
3
|
+
"version": "18.1.4",
|
|
4
4
|
"description": "Universal Plumeria plugin for various build tools",
|
|
5
5
|
"author": "Refirst 11",
|
|
6
6
|
"license": "MIT",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"dependencies": {
|
|
90
90
|
"@rollup/pluginutils": "^5.4.0",
|
|
91
91
|
"unplugin": "^3.0.0",
|
|
92
|
-
"@plumeria/utils": "^18.1.
|
|
92
|
+
"@plumeria/utils": "^18.1.4"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
95
|
"@swc/core": "1.15.47",
|