@cmmn/tools 1.6.11 → 1.6.12

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/bundle.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import {rollup, watch} from "rollup";
2
2
  import {getConfigOptions} from "./getConfigs.js";
3
3
  import {ConfigCreator} from "./rollup.config.js";
4
-
4
+ import fs from "fs";
5
+ import path from "path";
5
6
 
6
7
  export async function bundle(...options) {
7
8
  const configOptions = getConfigOptions({
@@ -19,7 +20,9 @@ export async function bundle(...options) {
19
20
  }
20
21
  const build = await rollup(config);
21
22
  for (let out of config.output){
22
- console.log(`SUCCESS: ${out.dir} ${out.entryFileNames.replace('[name]', Object.keys(config.input)[0])}`);
23
+ const file = path.join(out.dir, out.entryFileNames.replace('[name]', Object.keys(config.input)[0]));
24
+ const stat = fs.statSync(file);
25
+ console.log(`SUCCESS: ${file} (${(stat.size/1024/1024).toFixed(3)}Mb)`);
23
26
  await build.write(out);
24
27
  }
25
28
  }
@@ -15,7 +15,6 @@ import replace from '@rollup/plugin-replace';
15
15
  import sourcemaps from 'rollup-plugin-sourcemaps';
16
16
  import {Styles} from "./styles.js";
17
17
 
18
- // import postcssPresetEnv from 'postcss-preset-env'
19
18
  /**
20
19
  * @typedef {import(rollup).RollupOptions} RollupOptions
21
20
  * @typedef {import(rollup).OutputOptions} OutputOptions
@@ -84,9 +83,9 @@ export class ConfigCreator {
84
83
  entryFileNames: this.getOutputFileName(module, this.options.minify),
85
84
  // file: output,
86
85
  dir: this.outDir,
87
- sourcemap: true,
86
+ sourcemap: this.options.minify ? false : 'inline',
88
87
  format: module,
89
- globals: Array.isArray(this.options.external) ? Object.fromEntries(this.options.external.map(x => [x, x])) : this.options.external,
88
+ globals: module === 'umd' ? (Array.isArray(this.options.external) ? Object.fromEntries(this.options.external.map(x => [x, x])) : this.options.external) : [],
90
89
  assetFileNames: "assets/[name][extname]",
91
90
  name: this.options.global ?? 'global',
92
91
  }));
@@ -100,9 +99,9 @@ export class ConfigCreator {
100
99
  template: ({bundle}) => {
101
100
  const inject = Object.keys(bundle.bundle).map(key => {
102
101
  if (key.endsWith('css'))
103
- return `<link rel="stylesheet" href="${key}" >`;
102
+ return `<link rel="stylesheet" href="/${key}" >`;
104
103
  if (key.endsWith('js'))
105
- return `<script defer src="${key}"></script>`;
104
+ return `<script type="module" defer src="/${key}"></script>`;
106
105
  })
107
106
  const html = fs.readFileSync(path.join(this.root, this.options.html), 'utf8')
108
107
  return html.replace('</head>', inject.join('\n') + '</head>');
@@ -147,13 +146,15 @@ export class ConfigCreator {
147
146
  preventAssignment: true
148
147
  }),
149
148
  ...Styles(this.options),
149
+ commonjs({
150
+ requireReturnsDefault: "namespace",
151
+ transformMixedEsModules: true,
152
+ defaultIsModuleExports: true
153
+ }),
150
154
  nodeResolve({
151
155
  browser: this.options.browser,
152
156
  dedupe: this.options.dedupe || []
153
157
  }),
154
- commonjs({
155
- requireReturnsDefault: "namespace"
156
- }),
157
158
  sourcemaps(),
158
159
  builtins(),
159
160
  /*this.options.styles === 'modules' ? postCSS({
@@ -251,7 +252,7 @@ export class ConfigCreator {
251
252
 
252
253
  },
253
254
  plugins: this.plugins,
254
- treeshake: this.options.minify ? "smallest" : "recommended",
255
+ treeshake: this.options.minify ? "smallest" : "safest",
255
256
  watch: {
256
257
  exclude: this.getExternals().concat(path.join(this.root, this.outDir)),
257
258
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmmn/tools",
3
- "version": "1.6.11",
3
+ "version": "1.6.12",
4
4
  "description": "Compilation, bundling, code generator, testing.",
5
5
  "main": "dist/rollup.config.js",
6
6
  "type": "module",
@@ -57,7 +57,7 @@
57
57
  "fast-glob": "^3.2.11",
58
58
  "jest": "27.x.x",
59
59
  "less": "^4",
60
- "live-server": "1",
60
+ "live-server": "1.2.2",
61
61
  "postcss-import": "14",
62
62
  "postcss-modules": "*",
63
63
  "rollup": "^2",
@@ -80,5 +80,5 @@
80
80
  },
81
81
  "author": "",
82
82
  "license": "ISC",
83
- "gitHead": "2755b333808bf97f1d9454601c2a2c9a88e4a021"
83
+ "gitHead": "96da82c2b5c2a0c8bead5eeb8005d00261812153"
84
84
  }