@cmmn/tools 1.6.25 → 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.
@@ -165,11 +165,11 @@ export class ConfigCreator {
165
165
  commonjs({
166
166
  requireReturnsDefault: "namespace",
167
167
  transformMixedEsModules: true,
168
- defaultIsModuleExports: true
168
+ defaultIsModuleExports: true,
169
169
  }),
170
170
  nodeResolve({
171
171
  browser: this.options.browser,
172
- dedupe: this.options.dedupe || []
172
+ dedupe: this.options.dedupe || [],
173
173
  }),
174
174
  sourcemaps(),
175
175
  builtins(),
@@ -280,6 +280,7 @@ export class ConfigCreator {
280
280
 
281
281
  },
282
282
  plugins: this.plugins,
283
+ preserveEntrySignatures: true,
283
284
  treeshake: this.options.minify ? "recommended" : "safest",
284
285
  watch: {
285
286
  buildDelay: 300,
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.25",
3
+ "version": "1.6.27",
4
4
  "description": "Compilation, bundling, code generator, testing.",
5
5
  "main": "dist/rollup.config.js",
6
6
  "type": "module",
@@ -55,6 +55,7 @@
55
55
  "@types/sinon": "10.x.x",
56
56
  "@web/rollup-plugin-html": "^1.10.1",
57
57
  "fast-glob": "^3.2.11",
58
+ "file-uri-to-path": "2.x.x",
58
59
  "import-meta-resolve": "2",
59
60
  "jest": "27.x.x",
60
61
  "less": "^4",
@@ -82,5 +83,5 @@
82
83
  },
83
84
  "author": "",
84
85
  "license": "ISC",
85
- "gitHead": "69a1243e5836906a3e6e89ed0bfd7543f5a380a8"
86
+ "gitHead": "e4e3cb40b5249ed8022dbec45db78c2c1a91b6c5"
86
87
  }
package/serve/serve.js CHANGED
@@ -3,6 +3,7 @@ import path from "path";
3
3
  import fs from "fs";
4
4
  import liveServer from "live-server";
5
5
  import {resolve, moduleResolve} from 'import-meta-resolve';
6
+ import uri2path from "file-uri-to-path";
6
7
 
7
8
  export function serve(...options) {
8
9
  const configs = getConfigOptions({
@@ -14,7 +15,7 @@ export function serve(...options) {
14
15
  const server = await liveServer.start({
15
16
  root: root,
16
17
  file: 'index.html',
17
- port: x.port,
18
+ port: process.env.PORT || x.port,
18
19
  open: false,
19
20
  mount: x.mount && Object.entries(x.mount)
20
21
  .map(([from, to]) => [from, path.resolve(x.rootDir, to)])
@@ -35,15 +36,23 @@ function getModuleName(path) {
35
36
 
36
37
  const mappingCache = {};
37
38
 
38
- async function getFileName(moduleName, root){
39
+ // for resolve modules and files inside modules
40
+ async function getFileName(moduleName, root) {
39
41
  // console.log(moduleName, root);
40
42
  if (moduleName in mappingCache)
41
43
  return mappingCache[moduleName];
42
- const file = (await moduleResolve(moduleName, root, new Set(['module','import', 'browser', 'node'])));
43
- mappingCache[moduleName] = file.href;
44
- 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
+ }
45
55
  }
46
-
47
56
  const resolveESModule = (rootDir, configs) => async function (req, res, next) {
48
57
  const name = getModuleName(req.url);
49
58
  if (!name)
@@ -56,7 +65,7 @@ const resolveESModule = (rootDir, configs) => async function (req, res, next) {
56
65
  ? await getFileName(refererModule, 'file://' + rootDir + '/package.json')
57
66
  : 'file://' + rootDir + '/package.json';
58
67
  try {
59
- const file = (await getFileName(name, root)).substring('file:///'.length);
68
+ const file = uri2path(await getFileName(name, root));
60
69
  var stat = fs.statSync(file);
61
70
 
62
71
  res.writeHead(200, {
@@ -78,4 +87,4 @@ const resolveESModule = (rootDir, configs) => async function (req, res, next) {
78
87
  }
79
88
  res.end();
80
89
  return;
81
- }
90
+ }