olum-compiler 0.5.1 → 0.5.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.
package/bin/copySrc.js CHANGED
@@ -12,7 +12,15 @@ module.exports = function copySrc() {
12
12
  if (fs.existsSync(path.resolve(__dirname, "../public"))) remove(path.resolve(__dirname, "../public"));
13
13
  if (fs.existsSync(path.resolve(__dirname, "../src"))) remove(path.resolve(__dirname, "../src"));
14
14
  // copy
15
- copy(entryPoint, path.resolve(__dirname, "../src"));
15
+ copy(entryPoint, path.resolve(__dirname, "../src"), () => {
16
+ // modify main.js file import paths
17
+ const mainJsPath = path.resolve(__dirname, "../src/main.js");
18
+ if (fs.existsSync(mainJsPath)) {
19
+ let mainJsContent = fs.readFileSync(mainJsPath).toString();
20
+ mainJsContent = rewriteImports(mainJsContent);
21
+ fs.writeFileSync(mainJsPath, mainJsContent);
22
+ }
23
+ });
16
24
  copy(entryPoint2, path.resolve(__dirname, "../public"));
17
25
  resolve();
18
26
  } catch (err) {
package/bin/server.js CHANGED
@@ -17,13 +17,12 @@ function handleWsFile() {
17
17
  function getPath(entry, url) {
18
18
  entry = entry.endsWith("/") ? entry : entry + "/";
19
19
  url = url.startsWith("/") ? url.slice(1) : url;
20
- let trial_1 = path.resolve(entry + url);
21
- let trial_2 = path.resolve(entry + "../" + url);
22
- // console.log("getPath", { entry, url, trial_1, trial_2 });
23
-
24
- if (fs.existsSync(trial_1)) return trial_1;
25
- else if (fs.existsSync(trial_2)) return trial_2;
26
- else return null;
20
+ const paths = [
21
+ path.resolve(entry, url),
22
+ path.resolve(entry, "../", url),
23
+ path.resolve(process.cwd(), url),
24
+ ];
25
+ return paths.find(fs.existsSync) || null;
27
26
  }
28
27
  // todo handle https
29
28
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "olum-compiler",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "A module for compiling/bundling olumjs projects",
5
5
  "main": "bin/index.js",
6
6
  "bin": {