Skip to content

Commit f0cf003

Browse files
committed
feat: migrate from bulma-pull to @bulvar/bulma
1 parent dcd6c77 commit f0cf003

File tree

8 files changed

+4036
-1078
lines changed

8 files changed

+4036
-1078
lines changed

__tests__/__snapshots__/index.test.ts.snap

+495-1,062
Large diffs are not rendered by default.

__tests__/fixtures/simple/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createApp } from "vue";
22
import Test from "./Test.vue";
3-
import "@pathscale/bulma-pull-2981-css-var-only";
3+
import "@bulvar/bulma/css/bulma.css";
44
import "@pathscale/bulma-extensions-css-var";
55

66
createApp(Test).mount(document.body);

bun.lock

+3,509
Large diffs are not rendered by default.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pathscale/rollup-plugin-vue3-ui-css-purge",
3-
"version": "0.0.40",
3+
"version": "0.0.41",
44
"description": "Automatically remove unused CSS when using vue3-ui",
55
"keywords": [
66
"rollup",
@@ -59,7 +59,7 @@
5959
"@commitlint/config-angular": "^11.0.0",
6060
"@commitlint/prompt-cli": "^11.0.0",
6161
"@pathscale/bulma-extensions-css-var": "0.0.49-3",
62-
"@pathscale/bulma-pull-2981-css-var-only": "^0.9.6-1",
62+
"@bulvar/bulma": "^0.11.24",
6363
"@pathscale/vue3-ui": "^0.8.146",
6464
"@rollup/plugin-babel": "^5.2.2",
6565
"@rollup/plugin-commonjs": "^17.0.0",

src/analyzer.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import fs from "fs-extra";
77
import path from "path";
88
import traverse from "@babel/traverse";
99

10-
type Package = { main: string; module?: string };
10+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
11+
type Package = { [key: string]: any };
1112
type Data<K extends string, T> = { [P in K]?: T };
1213

1314
const parserOpts: jsparser.ParserOptions = {
@@ -43,6 +44,7 @@ const parserOpts: jsparser.ParserOptions = {
4344
const vue3ui = resolveSync("@pathscale/vue3-ui", {
4445
basedir: __dirname,
4546
packageFilter(pkg: Package) {
47+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
4648
if (pkg.module) pkg.main = pkg.module;
4749
return pkg;
4850
},
@@ -74,11 +76,8 @@ export function analyze(
7476
const whitelist = new Set<string>(["*", "html", "head", "body", "div", "app"]);
7577
let currentTag = "";
7678

77-
const idList = (Array.isArray(input)
78-
? input
79-
: typeof input === "object"
80-
? Object.values(input)
81-
: [input]
79+
const idList = (
80+
Array.isArray(input) ? input : typeof input === "object" ? Object.values(input) : [input]
8281
).map(id => normalizePath(path.resolve(id)));
8382

8483
const parser = new htmlparser.Parser(
@@ -98,8 +97,7 @@ export function analyze(
9897
onattribute(p, data) {
9998
for (const cl of data.split(" ")) whitelist.add(cl);
10099

101-
const prop = p.replace(":", "") // remove : from props like :loading -> loading
102-
100+
const prop = p.replace(":", ""); // remove : from props like :loading -> loading
103101

104102
if (kebabCase(currentTag).startsWith("v-")) {
105103
// optional
@@ -149,7 +147,9 @@ export function analyze(
149147
basedir: path.dirname(id),
150148
extensions,
151149
packageFilter(pkg: Package) {
150+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
152151
if (pkg.module) pkg.main = pkg.module;
152+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
153153
return pkg;
154154
},
155155
}),

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const generator = (options: Options = {}): Plugin => {
1616
"**/node_modules/@pathscale/vue3-ui/**/*.css",
1717
"**/node_modules/@pathscale/bulma-css-var-only/**/*.css",
1818
"**/node_modules/@pathscale/bulma-extensions-css-var/**/*.css",
19-
"**/node_modules/@pathscale/bulma-pull-2981-css-var-only/**/*.css",
19+
"**/node_modules/@bulvar/bulma/css/bulma.css",
2020
]);
2121

2222
let foundMain = false;

src/utils.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const resolveId = async (id: string, options: AsyncOpts = {}): Promise<st
3939

4040
/** Every project is expected to have a main file which imports both vue3-ui css packages */
4141
export const isMain = (code: string): boolean =>
42-
new RegExp("import.*@pathscale/bulma-pull").test(code) &&
42+
new RegExp("import.*@bulvar/bulma/css/bulma.css").test(code) &&
4343
new RegExp("import.*@pathscale/bulma-extensions").test(code);
4444

4545
export const getDeclaredVariables = (code: string): string[] =>
@@ -51,12 +51,12 @@ export const isVariableUsed = (v: string, code: string): boolean => code.include
5151
export const injectFakeBundle = (code: string): string =>
5252
`import './vue3-ui-bundle.css';
5353
${code
54-
.replace(/import.*@pathscale\/bulma-pull.*/gi, "")
54+
.replace(/import.*@bulvar\/bulma\/css\/bulma\.css.*/gi, "")
5555
.replace(/import.*@pathscale\/bulma-extensions.*/gi, "")
5656
.replace(/import.*user\.css.*/gi, "")}`;
5757

5858
export const makeVue3UiBundle = async (id: string): Promise<string> => {
59-
const bulmaCSSFile = await resolveId("@pathscale/bulma-pull-2981-css-var-only");
59+
const bulmaCSSFile = await resolveId("@bulvar/bulma/css/bulma.css");
6060
if (!bulmaCSSFile) throw new Error("TRANSFORM - BULMA CSS NOT FOUND");
6161

6262
const extensionsCSSFile = await resolveId("@pathscale/bulma-extensions-css-var");
@@ -88,7 +88,7 @@ export const makeVue3UiBundle = async (id: string): Promise<string> => {
8888
--${name}-a: 1;`,
8989
);
9090

91-
console.log(`TRANSFORM - USER CSS RESULT:\n`, userCSS);
91+
// console.log(`TRANSFORM - USER CSS RESULT:\n`, userCSS);
9292

9393
// replaces on bulmaCSS the definition of the variables swaping line for line
9494
const vars = getDeclaredVariables(userCSS);

test.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
TARGET="vue3.dev"
4+
COMMAND="build"
5+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6+
PARENT_DIR="$(dirname "$SCRIPT_DIR")"
7+
8+
# Build del plugin
9+
cd "$SCRIPT_DIR"
10+
npm run prepublishOnly
11+
12+
rm -rf "$PARENT_DIR/$TARGET/node_modules/@pathscale/rollup-plugin-vue3-ui-css-purge/dist"
13+
cp -r dist "$PARENT_DIR/$TARGET/node_modules/@pathscale/rollup-plugin-vue3-ui-css-purge/"
14+
15+
cd "$PARENT_DIR/$TARGET"
16+
npm run $COMMAND

0 commit comments

Comments
 (0)