@cmmn/tools 1.6.24 → 1.6.26

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.
@@ -104,9 +104,9 @@ export class ConfigCreator {
104
104
  template: (x) => {
105
105
  let inject = Object.keys(x.bundle.bundle).map(key => {
106
106
  if (key.endsWith('css'))
107
- return `<link rel="stylesheet" href="/${key}" >`;
107
+ return `<link rel="stylesheet" href="${this.options.base ?? ''}/${key}" >`;
108
108
  if (key.endsWith('js'))
109
- return `<script type="module" defer src="/${key}"></script>`;
109
+ return `<script type="module" defer src="${this.options.base ?? ''}/${key}"></script>`;
110
110
  }).join('\n');
111
111
  if (!this.options.minify) {
112
112
  const importMaps = Object.fromEntries(this.options.external
@@ -116,6 +116,9 @@ export class ConfigCreator {
116
116
  imports: importMaps
117
117
  })}</script>` + inject;
118
118
  }
119
+ if (this.options.base){
120
+ inject = `<base href="${this.options.base}">` + inject;
121
+ }
119
122
  const html = fs.readFileSync(path.join(this.root, this.options.html), 'utf8')
120
123
  return html.replace('</head>', inject + '</head>');
121
124
  }
@@ -162,11 +165,11 @@ export class ConfigCreator {
162
165
  commonjs({
163
166
  requireReturnsDefault: "namespace",
164
167
  transformMixedEsModules: true,
165
- defaultIsModuleExports: true
168
+ defaultIsModuleExports: true,
166
169
  }),
167
170
  nodeResolve({
168
171
  browser: this.options.browser,
169
- dedupe: this.options.dedupe || []
172
+ dedupe: this.options.dedupe || [],
170
173
  }),
171
174
  sourcemaps(),
172
175
  builtins(),
@@ -277,7 +280,8 @@ export class ConfigCreator {
277
280
 
278
281
  },
279
282
  plugins: this.plugins,
280
- treeshake: this.options.minify ? "smallest" : "safest",
283
+ preserveEntrySignatures: true,
284
+ treeshake: this.options.minify ? "recommended" : "safest",
281
285
  watch: {
282
286
  buildDelay: 300,
283
287
  clearScreen: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmmn/tools",
3
- "version": "1.6.24",
3
+ "version": "1.6.26",
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": "0826ee58578f567fc9eec12b9ab2aef9d0b3e8a2"
86
+ "gitHead": "c817edf78be83ca444f7eb3ba9516f0faf0f40cc"
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({
@@ -56,7 +57,7 @@ const resolveESModule = (rootDir, configs) => async function (req, res, next) {
56
57
  ? await getFileName(refererModule, 'file://' + rootDir + '/package.json')
57
58
  : 'file://' + rootDir + '/package.json';
58
59
  try {
59
- const file = (await getFileName(name, root)).substring('file:///'.length);
60
+ const file = uri2path(await getFileName(name, root));
60
61
  var stat = fs.statSync(file);
61
62
 
62
63
  res.writeHead(200, {