@genesislcap/rollup-builder 15.19.0 → 15.19.1
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/package.json +3 -4
- package/src/index.ts +0 -59
- package/src/options/index.ts +0 -2
- package/src/options/input.ts +0 -84
- package/src/options/output.ts +0 -35
- package/src/transformers/css-fragment.ts +0 -18
- package/src/transformers/html-fragment.ts +0 -23
- package/src/transformers/index.ts +0 -2
- package/tsconfig.json +0 -11
- package/tsconfig.tsbuildinfo +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/rollup-builder",
|
|
3
3
|
"description": "Rollup builder",
|
|
4
|
-
"version": "15.19.
|
|
4
|
+
"version": "15.19.1",
|
|
5
5
|
"license": "SEE LICENSE IN license.txt",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"lint:fix": "genx lint -l ox --fix"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@genesislcap/build-kit": "15.19.
|
|
19
|
+
"@genesislcap/build-kit": "15.19.1",
|
|
20
20
|
"@rollup/plugin-commonjs": "28.0.0",
|
|
21
21
|
"@rollup/plugin-json": "^5.0.0",
|
|
22
22
|
"@rollup/plugin-node-resolve": "^13.1.3",
|
|
@@ -38,6 +38,5 @@
|
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
|
-
}
|
|
42
|
-
"gitHead": "83695de98c2288c2e89992215cb391652f6c5eec"
|
|
41
|
+
}
|
|
43
42
|
}
|
package/src/index.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { BuildContext } from '@genesislcap/build-kit';
|
|
2
|
-
import { rm, green, white, bold, ms, run, resolveBin } from '@genesislcap/build-kit';
|
|
3
|
-
import consola from 'consola';
|
|
4
|
-
import { rollup, watch } from 'rollup';
|
|
5
|
-
import { getInputOptions, getOutputOptions } from './options';
|
|
6
|
-
|
|
7
|
-
export default async (ctx: BuildContext) => {
|
|
8
|
-
const {
|
|
9
|
-
dirs: { cwd },
|
|
10
|
-
cli: { isDev, isAnalyze, isBuild, options },
|
|
11
|
-
env: { isCI },
|
|
12
|
-
config: { externals, clean, copyAssets, entry },
|
|
13
|
-
pkg: { nameUnscoped },
|
|
14
|
-
} = ctx;
|
|
15
|
-
|
|
16
|
-
if (clean) {
|
|
17
|
-
await rm(['dist', '.rollup.cache']);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (Array.isArray(copyAssets)) {
|
|
21
|
-
const copyfiles = await resolveBin('copyfiles');
|
|
22
|
-
copyAssets.forEach((glob) => {
|
|
23
|
-
run(cwd, `${copyfiles} --verbose --up 1 src/${glob} ./dist/esm`);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const start = Date.now();
|
|
28
|
-
const openStats = options.open && !isCI;
|
|
29
|
-
const input = getInputOptions(externals, isAnalyze, openStats, entry);
|
|
30
|
-
const output = getOutputOptions(externals, isAnalyze, isDev, nameUnscoped);
|
|
31
|
-
const files = output.map((o) => o.file);
|
|
32
|
-
consola.log(white(`\n${bold(input.input)} → ${bold(files.join(', '))}...`));
|
|
33
|
-
|
|
34
|
-
if (isDev) {
|
|
35
|
-
const watchOptions = {
|
|
36
|
-
...input,
|
|
37
|
-
output,
|
|
38
|
-
};
|
|
39
|
-
const watcher = watch(watchOptions);
|
|
40
|
-
watcher.on('event', (event) => {
|
|
41
|
-
if (event.code === 'BUNDLE_END') {
|
|
42
|
-
event.result.close();
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
} else if (isAnalyze || isBuild) {
|
|
46
|
-
const bundle = await rollup(input);
|
|
47
|
-
await Promise.all(output.map(bundle.write));
|
|
48
|
-
await bundle.close();
|
|
49
|
-
consola.success(
|
|
50
|
-
green(
|
|
51
|
-
`bundled ${bold(bundle.watchFiles.length)} files → ${bold(files.join(', '))} in ${bold(
|
|
52
|
-
ms(Date.now() - start),
|
|
53
|
-
)}`,
|
|
54
|
-
),
|
|
55
|
-
);
|
|
56
|
-
} else {
|
|
57
|
-
throw new Error(`Unrecognized command: ${JSON.stringify(options)}`);
|
|
58
|
-
}
|
|
59
|
-
};
|
package/src/options/index.ts
DELETED
package/src/options/input.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import commonJS from '@rollup/plugin-commonjs';
|
|
2
|
-
import json from '@rollup/plugin-json';
|
|
3
|
-
import resolve from '@rollup/plugin-node-resolve';
|
|
4
|
-
import typescript from '@rollup/plugin-typescript';
|
|
5
|
-
import type { InputOption, InputOptions } from 'rollup';
|
|
6
|
-
import filesize from 'rollup-plugin-filesize';
|
|
7
|
-
import litcss from 'rollup-plugin-lit-css';
|
|
8
|
-
import styles from 'rollup-plugin-styles';
|
|
9
|
-
import transformTaggedTemplate from 'rollup-plugin-transform-tagged-template';
|
|
10
|
-
import { visualizer } from 'rollup-plugin-visualizer';
|
|
11
|
-
import { transformCSSFragment, transformHTMLFragment } from '../transformers';
|
|
12
|
-
|
|
13
|
-
const parserOptions = {
|
|
14
|
-
sourceType: 'module',
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// https://rollupjs.org/configuration-options/
|
|
18
|
-
export const getInputOptions = (
|
|
19
|
-
globals: Record<string, string>,
|
|
20
|
-
analyze: boolean,
|
|
21
|
-
open: boolean,
|
|
22
|
-
input: InputOption = 'src/index.ts',
|
|
23
|
-
): InputOptions => ({
|
|
24
|
-
context: 'this',
|
|
25
|
-
input,
|
|
26
|
-
// modules which shouldn't be included in the bundle
|
|
27
|
-
external: globals ? Object.keys(globals) : undefined,
|
|
28
|
-
onwarn(warning, warn) {
|
|
29
|
-
// The IIFE export doesn't have a namespace since component exports
|
|
30
|
-
// are expected to be top-level objects
|
|
31
|
-
if (warning.code === 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT') {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const nodeModulesNamespaceConflict =
|
|
36
|
-
warning.reexporter && warning.reexporter.indexOf('node_modules') !== -1;
|
|
37
|
-
const nodeModulesCircularDependency =
|
|
38
|
-
warning.importer && warning.importer.indexOf('node_modules') !== -1;
|
|
39
|
-
|
|
40
|
-
if (nodeModulesNamespaceConflict || nodeModulesCircularDependency) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
warn(warning);
|
|
45
|
-
},
|
|
46
|
-
plugins: [
|
|
47
|
-
resolve({
|
|
48
|
-
browser: true,
|
|
49
|
-
}),
|
|
50
|
-
commonJS(),
|
|
51
|
-
typescript({
|
|
52
|
-
outputToFilesystem: false,
|
|
53
|
-
sourceMap: false,
|
|
54
|
-
tsconfig: 'tsconfig.json',
|
|
55
|
-
}),
|
|
56
|
-
json(),
|
|
57
|
-
styles({ mode: 'emit' }),
|
|
58
|
-
litcss({ specifier: '@microsoft/fast-element' }),
|
|
59
|
-
transformTaggedTemplate({
|
|
60
|
-
tagsToProcess: ['css'],
|
|
61
|
-
transformer: transformCSSFragment,
|
|
62
|
-
parserOptions,
|
|
63
|
-
}),
|
|
64
|
-
transformTaggedTemplate({
|
|
65
|
-
tagsToProcess: ['html'],
|
|
66
|
-
transformer: transformHTMLFragment,
|
|
67
|
-
parserOptions,
|
|
68
|
-
}),
|
|
69
|
-
filesize({
|
|
70
|
-
showMinifiedSize: false,
|
|
71
|
-
showBrotliSize: true,
|
|
72
|
-
}),
|
|
73
|
-
analyze &&
|
|
74
|
-
visualizer((outputOptions) => {
|
|
75
|
-
return {
|
|
76
|
-
title: `Rollup Visualizer - ${outputOptions.file}`,
|
|
77
|
-
filename: outputOptions.file.replace('.js', '.stats.html'),
|
|
78
|
-
gzipSize: true,
|
|
79
|
-
brotliSize: true,
|
|
80
|
-
open,
|
|
81
|
-
};
|
|
82
|
-
}),
|
|
83
|
-
].filter(Boolean),
|
|
84
|
-
});
|
package/src/options/output.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import terser from '@rollup/plugin-terser';
|
|
2
|
-
import type { OutputOptions, ModuleFormat, OutputPlugin } from 'rollup';
|
|
3
|
-
|
|
4
|
-
export const getOutputOptions = (
|
|
5
|
-
globals: Record<string, string>,
|
|
6
|
-
isAnalyze: boolean,
|
|
7
|
-
isDev: boolean,
|
|
8
|
-
packageName: string,
|
|
9
|
-
): OutputOptions[] => {
|
|
10
|
-
const unminified: OutputOptions = {
|
|
11
|
-
file: `dist/${packageName}.js`,
|
|
12
|
-
format: 'esm' as ModuleFormat,
|
|
13
|
-
globals,
|
|
14
|
-
};
|
|
15
|
-
const minified: OutputOptions = {
|
|
16
|
-
file: `dist/${packageName}.min.js`,
|
|
17
|
-
format: 'esm' as ModuleFormat,
|
|
18
|
-
plugins: [terser() as unknown as OutputPlugin],
|
|
19
|
-
globals,
|
|
20
|
-
};
|
|
21
|
-
const iife: OutputOptions = {
|
|
22
|
-
file: `dist/${packageName}.iife.min.js`,
|
|
23
|
-
format: 'iife' as ModuleFormat,
|
|
24
|
-
plugins: [terser() as unknown as OutputPlugin],
|
|
25
|
-
globals,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
if (isDev) {
|
|
29
|
-
return [unminified];
|
|
30
|
-
} else if (isAnalyze) {
|
|
31
|
-
return [minified];
|
|
32
|
-
} else {
|
|
33
|
-
return [unminified, minified, iife];
|
|
34
|
-
}
|
|
35
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/* eslint prefer-named-capture-group: "off" */
|
|
2
|
-
const newlines = /\n/g;
|
|
3
|
-
const separators = /\s*([{};])\s*/g;
|
|
4
|
-
const lastProp = /;\s*(\})/g;
|
|
5
|
-
const extraSpaces = /\s\s+/g;
|
|
6
|
-
const endingSpaces = / ?\s+$/g;
|
|
7
|
-
|
|
8
|
-
export function transformCSSFragment(data) {
|
|
9
|
-
// newlines
|
|
10
|
-
data = data.replace(newlines, '');
|
|
11
|
-
// Remove extra space, but not too much
|
|
12
|
-
data = data.replace(separators, '$1');
|
|
13
|
-
// Remove semicolons followed by property list end
|
|
14
|
-
data = data.replace(lastProp, '$1');
|
|
15
|
-
// space might be between property values or between selectors
|
|
16
|
-
data = data.replace(endingSpaces, ' ');
|
|
17
|
-
return data.replace(extraSpaces, ' ');
|
|
18
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/* eslint prefer-named-capture-group: "off" */
|
|
2
|
-
const onlySpace = /^\s+$/g;
|
|
3
|
-
const spaceBetforeTagClose = /\s+(>)/g;
|
|
4
|
-
const spaceBetweenTags = /(>)\s+(<)/g;
|
|
5
|
-
const spaceBetweenAttrs = /(["'\w])(?!\s*>)\s+/g;
|
|
6
|
-
const openEnded = /(?:[^="'\w])?(["'\w])\s*$/g;
|
|
7
|
-
|
|
8
|
-
export function transformHTMLFragment(data) {
|
|
9
|
-
// if the chunk is only space, collapse and return it
|
|
10
|
-
if (data.match(onlySpace)) {
|
|
11
|
-
return data.replace(onlySpace, ' ');
|
|
12
|
-
}
|
|
13
|
-
// remove space before tag close
|
|
14
|
-
data = data.replace(spaceBetforeTagClose, '$1');
|
|
15
|
-
// remove space between tags
|
|
16
|
-
data = data.replace(spaceBetweenTags, '$1$2');
|
|
17
|
-
// remove space between attributes
|
|
18
|
-
data = data.replace(spaceBetweenAttrs, '$1 ');
|
|
19
|
-
if (data.match(openEnded)) {
|
|
20
|
-
return data.trimStart();
|
|
21
|
-
}
|
|
22
|
-
return data.trim();
|
|
23
|
-
}
|
package/tsconfig.json
DELETED
package/tsconfig.tsbuildinfo
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"root":["./src/index.ts","./src/options/index.ts","./src/options/input.ts","./src/options/output.ts","./src/transformers/css-fragment.ts","./src/transformers/html-fragment.ts","./src/transformers/index.ts"],"version":"5.9.2"}
|