vaderjs 2.3.0 → 2.3.2

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.
Files changed (3) hide show
  1. package/cli.ts +21 -12
  2. package/main.js +8 -8
  3. package/package.json +1 -1
package/cli.ts CHANGED
@@ -36,7 +36,7 @@ async function run(cmd: string, args: string[] = []) {
36
36
  }
37
37
  }
38
38
 
39
- export async function init() {
39
+ export async function init() {
40
40
  console.log("🚀 Welcome to Vader.js project initializer!");
41
41
 
42
42
  const cwd = process.cwd();
@@ -134,11 +134,11 @@ export default function Counter() {
134
134
  console.log(`Created package.json`);
135
135
  }
136
136
 
137
- // Install dependencies: vaderjs + optionally tailwindcss, postcss plugins
137
+ // Install dependencies: vaderjs + optionally tailwindcss, postcss plugins, autoprefixer
138
138
  console.log("Installing dependencies with Bun...");
139
- const deps = ["vaderjs"];
139
+ const deps = ["vaderjs", "autoprefixer"];
140
140
  if (wantsTailwind) {
141
- deps.push("tailwindcss", "@tailwindcss/postcss", "postcss-cli");
141
+ deps.push("tailwindcss@4", "@tailwindcss/postcss", "postcss-cli");
142
142
  }
143
143
  await run("bun", ["install", ...deps]);
144
144
  console.log("✅ Dependencies installed.");
@@ -155,23 +155,35 @@ export default function Counter() {
155
155
  await fs.writeFile(path.join(projectDir, "tailwind.config.cjs"), tailwindConfig);
156
156
  console.log("Created tailwind.config.cjs");
157
157
 
158
- const postcssConfig = `module.exports = {
158
+ const postcssConfig = `export default {
159
159
  plugins: {
160
- tailwindcss: {},
160
+ "@tailwindcss/postcss": {},
161
161
  autoprefixer: {},
162
- },
162
+ }
163
163
  };`;
164
164
  await fs.writeFile(path.join(projectDir, "postcss.config.cjs"), postcssConfig);
165
165
  console.log("Created postcss.config.cjs");
166
166
  }
167
167
 
168
+ // Create vaderjs.config.ts regardless, add Tailwind plugin if needed
169
+ const vaderConfig = `import defineConfig from "vaderjs/config";
170
+ ${wantsTailwind ? 'import tailwind from "vaderjs/plugins/tailwind";' : ''}
171
+
172
+ export default defineConfig({
173
+ port: 3000,
174
+ plugins: [${wantsTailwind ? "tailwind" : ""}],
175
+ });`;
176
+
177
+ await fs.writeFile(path.join(projectDir, "vaderjs.config.ts"), vaderConfig);
178
+ console.log("Created vaderjs.config.ts");
179
+
168
180
  // Create jsconfig.json for VSCode/IDE support
169
181
  const jsConfig = {
170
182
  compilerOptions: {
171
183
  jsx: "react",
172
184
  jsxFactory: "Vader.createElement",
173
- jsxFragmentFactory: "Fragment"
174
- }
185
+ jsxFragmentFactory: "Fragment",
186
+ },
175
187
  };
176
188
  await fs.writeFile(path.join(projectDir, "jsconfig.json"), JSON.stringify(jsConfig, null, 2));
177
189
  console.log("Created jsconfig.json");
@@ -181,6 +193,3 @@ export default function Counter() {
181
193
  console.log(`Run cd ${projectDir} to navigate into the project folder`);
182
194
  console.log("Run `bun run dev` or your build script to get started.");
183
195
  }
184
-
185
-
186
-
package/main.js CHANGED
@@ -82,7 +82,7 @@ const vaderAPI = {
82
82
 
83
83
  async function loadConfig() {
84
84
  try {
85
- const configModule = await import(path.join(PROJECT_ROOT, "vader.config.js"));
85
+ const configModule = await import(path.join(PROJECT_ROOT, "vaderjs.config.js"));
86
86
  return configModule.default || configModule;
87
87
  } catch {
88
88
  logger.warn("No 'vader.config.js' found, using defaults.");
@@ -204,7 +204,6 @@ async function copyPublicAssets() {
204
204
  }
205
205
  }
206
206
 
207
-
208
207
  async function buildAppEntrypoints(isDev = false) {
209
208
  if (!fsSync.existsSync(APP_DIR)) {
210
209
  logger.warn("No '/app' directory found, skipping app entrypoint build.");
@@ -216,7 +215,7 @@ async function copyPublicAssets() {
216
215
  await fs.mkdir(DIST_DIR, { recursive: true });
217
216
  }
218
217
 
219
- const devClientScript = isDev ? `
218
+ const devClientScript = isDev ? `
220
219
  <script>
221
220
  new WebSocket("ws://" + location.host + "/__hmr").onmessage = (msg) => {
222
221
  if (msg.data === "reload") location.reload();
@@ -231,13 +230,13 @@ async function copyPublicAssets() {
231
230
  }));
232
231
 
233
232
  for (const { name, path: entryPath } of entries) {
234
- // Ensure correct path handling for subdirectories
233
+ // Check for the specific case where 'name' could be 'index.js' and prevent duplication
235
234
  const outDir = path.join(DIST_DIR, name === 'index' ? '' : name);
236
- const outJsPath = path.join(outDir, `index.js`); // Output JavaScript file path
237
-
235
+ const outJsPath = path.join(outDir, 'index.js'); // Output JavaScript file path
236
+
238
237
  // Ensure the output directory exists
239
238
  await fs.mkdir(outDir, { recursive: true });
240
-
239
+
241
240
  // **FIXED CSS HANDLING**: Find, copy, and correctly link CSS files
242
241
  const cssLinks = [];
243
242
  const cssContent = await fs.readFile(entryPath, "utf8");
@@ -273,8 +272,9 @@ async function copyPublicAssets() {
273
272
  <body>
274
273
  <div id="app"></div>
275
274
  <script type="module">
276
- import App from '/${name}/index.js';
275
+ import App from '${name !== 'index' ? name : ''}/index.js';
277
276
  import * as Vader from '/src/vader/index.js';
277
+ window.Vader = Vader
278
278
  Vader.render(Vader.createElement(App, null), document.getElementById("app"));
279
279
  </script>
280
280
  ${devClientScript}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vaderjs",
3
- "version": "2.3.0",
3
+ "version": "2.3.2",
4
4
  "description": "A simple and powerful JavaScript library for building modern web applications.",
5
5
  "bin": {
6
6
  "vaderjs": "./main.js"