olum-compiler 2.1.3 → 2.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/README.md CHANGED
@@ -6,4 +6,75 @@
6
6
  </p>
7
7
 
8
8
  # Olum-Compiler
9
- See [Documentation](https://olumjs.top/docs)
9
+ A module for compiling/bundling Olumjs projects.
10
+
11
+ See [Documentation](https://olumjs.top/docs)
12
+
13
+ ## Contributing
14
+ Thanks for wanting to help make Olum-Compiler better! 💙 Bug fixes, new features, and docs improvements are all welcome.
15
+
16
+ ### The branch rule (important)
17
+ Olum-Compiler uses **one branch per version** (`v2.1.0`, `v2.1.1`, ...). Each new version branch is created from the previous one, so the **latest version branch always contains everything**.
18
+
19
+ > ✅ Always base your work on the **latest** version branch (currently **`v2.1.3`**).
20
+ > ❌ Never base it on an older one like `v2.1.0` — your PR will be missing recent changes and will conflict.
21
+
22
+ Not sure which one is the latest? Check the branch list on GitHub (or run `git branch -r`) and pick the highest version number.
23
+
24
+ ### Step by step
25
+ 1. **Fork** the repo and clone your fork:
26
+ ```bash
27
+ git clone https://github.com/<your-username>/olum-compiler.git
28
+ cd olum-compiler
29
+ ```
30
+ 2. **Check out the latest version branch** (replace `v2.1.3` with the newest one):
31
+ ```bash
32
+ git fetch origin
33
+ git checkout v2.1.3
34
+ ```
35
+ 3. **Create your own branch from it** — a copy of the latest version with your changes on top:
36
+ ```bash
37
+ git checkout -b feat/my-awesome-feature
38
+ # or: git checkout -b fix/describe-the-bug
39
+ ```
40
+ 4. **Install dependencies:**
41
+ ```bash
42
+ npm install
43
+ ```
44
+ 5. **Make your change.** Source lives in `lib/` and the CLI entry in `bin/`. Keep the change focused: one feature or fix per PR.
45
+ 6. **Run the tests** and add or update them in `tests/` when behavior changes:
46
+ ```bash
47
+ npm test
48
+ ```
49
+ 7. **Update the docs** if your change affects user-facing behavior (see below).
50
+ 8. **Commit** using a clear message, following the existing style:
51
+ ```
52
+ feat: support alias in import statements
53
+ fix: hmr goes into infinite loop if multiple apps running at the same time
54
+ ```
55
+ 9. **Push** your branch to your fork:
56
+ ```bash
57
+ git push origin feat/my-awesome-feature
58
+ ```
59
+ 10. **Open a Pull Request** against the **latest version branch** (e.g. `v2.1.3`) — *not* `v2.1.0` or an older version. Describe what changed, why, and include a small example if it's user-facing.
60
+
61
+ ### Docs are part of the change
62
+ User-facing documentation lives on [olumjs.top/docs](https://olumjs.top/docs). If your PR changes behavior or adds a feature, mention in the PR description what the docs need so they can be updated alongside it. No docs change needed? Just say so (e.g. internal refactor).
63
+
64
+ ### PR checklist
65
+ - [ ] Branched from the **latest** version branch (not an older one)
66
+ - [ ] PR targets the latest version branch
67
+ - [ ] `npm test` passes
68
+ - [ ] Docs impact noted in the PR description
69
+ - [ ] One focused change, clear commit messages
70
+
71
+ Questions or unsure about an idea? Ask in [Discord](https://discord.gg/2zK7tb2Cg9) before you start — we're happy to help.
72
+
73
+ ## Community
74
+ - [X](https://x.com/olumjs)
75
+ - [Bluesky](https://bsky.app/profile/olumjs.bsky.social)
76
+ - [Discord](https://discord.gg/2zK7tb2Cg9)
77
+
78
+ ## Contact
79
+ - General: [hello@olumjs.top](mailto:hello@olumjs.top)
80
+ - Security: [security@olumjs.top](mailto:security@olumjs.top) — please report vulnerabilities here privately rather than opening a public issue
package/bin/bundle.js CHANGED
@@ -3,6 +3,21 @@ const fs = require("fs");
3
3
  const colors = require("../lib/colors");
4
4
  const spawn = require("../lib/cross-spawn");
5
5
  const { useLocalCore, localLibs, optionalLibs } = require("../lib/coreLibs");
6
+ const env = require("../lib/env");
7
+
8
+ function envDefine() {
9
+ const vars = env.load();
10
+ const runtime = "globalThis.process.env";
11
+ const define = {
12
+ "process.env": runtime,
13
+ "global.process.env": runtime,
14
+ "globalThis.process.env": runtime,
15
+ };
16
+ for (const key of Object.keys(vars))
17
+ if (/^[A-Za-z_$][\w$]*$/.test(key))
18
+ define[`process.env.${key}`] = JSON.stringify(vars[key]);
19
+ return define;
20
+ }
6
21
 
7
22
  const cwd = process.cwd();
8
23
  const public = path.resolve(__dirname, "../public");
@@ -153,7 +168,7 @@ async function bundle(bootAt) {
153
168
  resolve: { alias },
154
169
  plugins: base === "/" ? [] : [staticUrlPlugin(base)],
155
170
 
156
- define: { "globalThis.__OLUM_DEV__": "false" },
171
+ define: { "globalThis.__OLUM_DEV__": "false", ...envDefine() },
157
172
  build: {
158
173
  outDir,
159
174
  emptyOutDir: true,
package/bin/copySrc.js CHANGED
@@ -5,6 +5,7 @@ const importMap = require("../lib/importMap");
5
5
  const usage = require("../lib/usage");
6
6
  const splitJsBarrels = require("../lib/jsBarrels");
7
7
  const resolveAliases = require("../lib/alias");
8
+ const env = require("../lib/env");
8
9
 
9
10
  const cwd = process.cwd();
10
11
  const projectRoot = cwd.replace(/\/module$/, "");
@@ -37,6 +38,11 @@ function injectIndexHtml(indexHtmlPath) {
37
38
  process.env.NODE_ENV === "production"
38
39
  ? ""
39
40
  : `<script>globalThis.__OLUM_DEV__ = true;</script>\n`;
41
+
42
+ indexHtmlContent = indexHtmlContent.replace(
43
+ /<head[^>]*>/i,
44
+ (tag) => `${tag}\n${env.scriptTag()}`,
45
+ );
40
46
  indexHtmlContent = indexHtmlContent.replace(
41
47
  /<\/body>/,
42
48
  `\n<div id="olum-app"></div>\n${devFlagTag}${importMapTag}<script defer type="module" src="../src/main.js"></script>\n${devtoolScriptContent}</body>`,
package/lib/changes.txt CHANGED
@@ -1,6 +0,0 @@
1
- change /home/eissapk/olum/template-compiler/src/page.html
2
- change /home/eissapk/olum/template-compiler/src/page.html
3
- change /home/eissapk/olum/template-compiler/src/page.html
4
- change /home/eissapk/olum/template-compiler/src/page.html
5
- change /home/eissapk/olum/template-compiler/src/page.html
6
- change /home/eissapk/olum/template-compiler/src/page.html
package/lib/env.js ADDED
@@ -0,0 +1,48 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ const projectRoot = process.cwd().replace(/\/module$/, "");
5
+
6
+ function files() {
7
+ const mode =
8
+ process.env.NODE_ENV === "production" ? "production" : "development";
9
+ return [".env", `.env.${mode}`].map((name) => path.join(projectRoot, name));
10
+ }
11
+
12
+ function parse(src) {
13
+ const vars = {};
14
+ src.split(/\r?\n/).forEach((line) => {
15
+ const m = line.match(/^\s*(?:export\s+)?([\w.-]+)\s*=\s*(.*)?\s*$/);
16
+ if (!m) return;
17
+ let value = (m[2] || "").trim();
18
+ const quote = value[0];
19
+ if (
20
+ (quote === '"' || quote === "'" || quote === "`") &&
21
+ value.lastIndexOf(quote) > 0
22
+ ) {
23
+ value = value.slice(1, value.lastIndexOf(quote));
24
+ if (quote === '"') value = value.replace(/\\n/g, "\n");
25
+ } else {
26
+ value = value.replace(/\s+#.*$/, "");
27
+ }
28
+ vars[m[1]] = value;
29
+ });
30
+ return vars;
31
+ }
32
+
33
+ function load() {
34
+ return files().reduce(
35
+ (vars, file) =>
36
+ fs.existsSync(file)
37
+ ? Object.assign(vars, parse(fs.readFileSync(file, "utf8")))
38
+ : vars,
39
+ {},
40
+ );
41
+ }
42
+
43
+ function scriptTag() {
44
+ const json = JSON.stringify(load()).replace(/</g, "\\u003c");
45
+ return `<script>window.process = window.process || {}; process.env = Object.assign(process.env || {}, ${json});</script>`;
46
+ }
47
+
48
+ module.exports = { load, parse, scriptTag, files };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "olum-compiler",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "description": "A module for compiling/bundling olumjs projects",
5
5
  "main": "bin/index.js",
6
6
  "bin": {