@cmmn/tools 1.6.26 → 1.6.27

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/bundle/styles.js CHANGED
@@ -1,4 +1,3 @@
1
- import loader from 'postcss-modules/build/css-loader-core/loader.js';
2
1
  import postCssImport from 'postcss-import';
3
2
  import postCssAssets from 'postcss-assets';
4
3
  import cssModules from '@modular-css/rollup';
@@ -6,22 +5,6 @@ import slug from "unique-slug";
6
5
  import styles from "rollup-plugin-styles";
7
6
  import {images} from "./images.js";
8
7
 
9
- class Loader extends loader.default {
10
- failStart = '/' + process.cwd();
11
-
12
- fetch(_newPath, relativeTo, _trace) {
13
- if (relativeTo.startsWith(this.failStart))
14
- relativeTo = relativeTo.substring(1);
15
- // let newPath = _newPath.replace(/^["']|["']$/g, "");
16
- // let relativeDir = path.dirname(relativeTo),
17
- // rootRelativePath = path.resolve(relativeDir, newPath),
18
- // fileRelativePath = path.resolve(path.join(this.root, relativeDir), newPath);
19
- // relativeTo = path.relative(process.cwd(), relativeTo);
20
- // console.log({root: this.root, newPath, relativeTo, relativeDir, rootRelativePath, fileRelativePath});
21
- return super.fetch(_newPath, relativeTo, _trace);
22
- }
23
- }
24
-
25
8
  /**
26
9
  *
27
10
  * @param {ConfigCreator} config
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmmn/tools",
3
- "version": "1.6.26",
3
+ "version": "1.6.27",
4
4
  "description": "Compilation, bundling, code generator, testing.",
5
5
  "main": "dist/rollup.config.js",
6
6
  "type": "module",
@@ -83,5 +83,5 @@
83
83
  },
84
84
  "author": "",
85
85
  "license": "ISC",
86
- "gitHead": "c817edf78be83ca444f7eb3ba9516f0faf0f40cc"
86
+ "gitHead": "e4e3cb40b5249ed8022dbec45db78c2c1a91b6c5"
87
87
  }
package/serve/serve.js CHANGED
@@ -15,7 +15,7 @@ export function serve(...options) {
15
15
  const server = await liveServer.start({
16
16
  root: root,
17
17
  file: 'index.html',
18
- port: x.port,
18
+ port: process.env.PORT || x.port,
19
19
  open: false,
20
20
  mount: x.mount && Object.entries(x.mount)
21
21
  .map(([from, to]) => [from, path.resolve(x.rootDir, to)])
@@ -36,15 +36,23 @@ function getModuleName(path) {
36
36
 
37
37
  const mappingCache = {};
38
38
 
39
- async function getFileName(moduleName, root){
39
+ // for resolve modules and files inside modules
40
+ async function getFileName(moduleName, root) {
40
41
  // console.log(moduleName, root);
41
42
  if (moduleName in mappingCache)
42
43
  return mappingCache[moduleName];
43
- const file = (await moduleResolve(moduleName, root, new Set(['module','import', 'browser', 'node'])));
44
- mappingCache[moduleName] = file.href;
45
- return file.href;
44
+ let file;
45
+ if (moduleName.match('\.[cm]?js')) {
46
+ const module = moduleName.match(/^(@[^/]+\/)?[^/]+/)[0];
47
+ const main = (await moduleResolve(module, root, new Set(['module', 'import', 'browser', 'main', 'node'])));
48
+ const file = main.href.replace(new RegExp('node_modules/' + module + '.*$'), 'node_modules/' + moduleName);
49
+ console.log(file)
50
+ return mappingCache[moduleName] = file;
51
+ } else {
52
+ const file = (await moduleResolve(moduleName, root, new Set(['module', 'import', 'browser', 'main', 'node'])));
53
+ return mappingCache[moduleName] = file.href;
54
+ }
46
55
  }
47
-
48
56
  const resolveESModule = (rootDir, configs) => async function (req, res, next) {
49
57
  const name = getModuleName(req.url);
50
58
  if (!name)
@@ -79,4 +87,4 @@ const resolveESModule = (rootDir, configs) => async function (req, res, next) {
79
87
  }
80
88
  res.end();
81
89
  return;
82
- }
90
+ }