@cmmn/tools 1.6.14 → 1.6.15
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/rollup.config.js +17 -13
- package/compile/compile.js +8 -2
- package/package.json +2 -2
package/bundle/rollup.config.js
CHANGED
|
@@ -14,7 +14,6 @@ import alias from '@rollup/plugin-alias';
|
|
|
14
14
|
import replace from '@rollup/plugin-replace';
|
|
15
15
|
import sourcemaps from 'rollup-plugin-sourcemaps';
|
|
16
16
|
import {Styles} from "./styles.js";
|
|
17
|
-
|
|
18
17
|
/**
|
|
19
18
|
* @typedef {import(rollup).RollupOptions} RollupOptions
|
|
20
19
|
* @typedef {import(rollup).OutputOptions} OutputOptions
|
|
@@ -91,7 +90,7 @@ export class ConfigCreator {
|
|
|
91
90
|
name: this.options.global ?? 'global',
|
|
92
91
|
sourcemapPathTransform: sourceMap => {
|
|
93
92
|
const p = path.relative(this.root, path.resolve(this.outDir, sourceMap));
|
|
94
|
-
return path.join('/',this.options.package, p);
|
|
93
|
+
return path.join('/', this.options.package, p);
|
|
95
94
|
}
|
|
96
95
|
}));
|
|
97
96
|
}
|
|
@@ -102,19 +101,22 @@ export class ConfigCreator {
|
|
|
102
101
|
dir: this.outDir,
|
|
103
102
|
inject: false,
|
|
104
103
|
template: (x) => {
|
|
105
|
-
|
|
104
|
+
let inject = Object.keys(x.bundle.bundle).map(key => {
|
|
106
105
|
if (key.endsWith('css'))
|
|
107
106
|
return `<link rel="stylesheet" href="/${key}" >`;
|
|
108
107
|
if (key.endsWith('js'))
|
|
109
108
|
return `<script type="module" defer src="/${key}"></script>`;
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
109
|
+
}).join('\n');
|
|
110
|
+
if (!this.options.minify) {
|
|
111
|
+
const importMaps = Object.fromEntries(this.options.external
|
|
112
|
+
.map(key => key.replace('.*', '/'))
|
|
113
|
+
.map(key => [key, `/external/${this.options.alias[key] ?? key}`]));
|
|
114
|
+
inject = `<script type="importmap" >${JSON.stringify({
|
|
115
|
+
imports: importMaps
|
|
116
|
+
})}</script>` + inject;
|
|
117
|
+
}
|
|
116
118
|
const html = fs.readFileSync(path.join(this.root, this.options.html), 'utf8')
|
|
117
|
-
return html.replace('</head>',
|
|
119
|
+
return html.replace('</head>', inject + '</head>');
|
|
118
120
|
}
|
|
119
121
|
});
|
|
120
122
|
}
|
|
@@ -194,9 +196,11 @@ export class ConfigCreator {
|
|
|
194
196
|
];
|
|
195
197
|
if (this.options.alias) {
|
|
196
198
|
result.unshift(alias({
|
|
197
|
-
entries: this.options.alias
|
|
199
|
+
entries: Object.entries(this.options.alias).map(([key, value]) => ({
|
|
200
|
+
find: key,
|
|
201
|
+
replacement: value
|
|
202
|
+
}))
|
|
198
203
|
}));
|
|
199
|
-
console.log(this.options.alias)
|
|
200
204
|
}
|
|
201
205
|
if (this.options.html || this.options.input.endsWith('.html')) {
|
|
202
206
|
result.push(this.html);
|
|
@@ -243,7 +247,7 @@ export class ConfigCreator {
|
|
|
243
247
|
[this.options.name]: path.join(this.root, this.options.input)
|
|
244
248
|
},
|
|
245
249
|
output: this.output,
|
|
246
|
-
external: this.getExternals(),
|
|
250
|
+
external: (this.options.minify && this.options.browser) ? [] : this.getExternals(),
|
|
247
251
|
manualChunks: this.options.chunks,
|
|
248
252
|
onwarn(warning) {
|
|
249
253
|
switch (warning.code) {
|
package/compile/compile.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ts from "ttypescript";
|
|
2
2
|
import {resolve, relative} from 'path';
|
|
3
|
-
|
|
3
|
+
import fs from "fs";
|
|
4
4
|
const rootDir = process.cwd();
|
|
5
5
|
|
|
6
6
|
export function compile(...flags) {
|
|
@@ -22,12 +22,18 @@ export function compile(...flags) {
|
|
|
22
22
|
builder.clean(rootDir);
|
|
23
23
|
builder.build(rootDir);
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
const cleanedBaseDirs = new Set();
|
|
26
26
|
function createProgram(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences) {
|
|
27
27
|
options.outDir = resolve(options.configFilePath, '../dist/esm');
|
|
28
28
|
options.declarationDir = resolve(options.configFilePath, '../dist/typings');
|
|
29
29
|
options.baseUrl = resolve(options.configFilePath, '../');
|
|
30
30
|
options.tsBuildInfoFile = resolve(options.configFilePath, '../dist/ts.buildinfo');
|
|
31
|
+
if (!cleanedBaseDirs.has(options.baseUrl)){
|
|
32
|
+
fs.rmSync(options.outDir, {recursive: true, force: true});
|
|
33
|
+
fs.rmSync(options.declarationDir, {recursive: true, force: true});
|
|
34
|
+
fs.rmSync(options.tsBuildInfoFile, {force: true});
|
|
35
|
+
cleanedBaseDirs.add(options.baseUrl);
|
|
36
|
+
}
|
|
31
37
|
console.log('\t', relative(process.cwd(), options.baseUrl));
|
|
32
38
|
return ts.createEmitAndSemanticDiagnosticsBuilderProgram(
|
|
33
39
|
rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmmn/tools",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.15",
|
|
4
4
|
"description": "Compilation, bundling, code generator, testing.",
|
|
5
5
|
"main": "dist/rollup.config.js",
|
|
6
6
|
"type": "module",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
},
|
|
82
82
|
"author": "",
|
|
83
83
|
"license": "ISC",
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "9e836ce57ea7b9e9143ab895e5506570c2b93645"
|
|
85
85
|
}
|