@soleil-se/build-app 1.0.2 → 1.2.0
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/LICENSE.md +1 -0
- package/package.json +18 -17
- package/rollup/api/getSveltePlugin.js +11 -6
- package/rollup/client.js +4 -5
- package/rollup/plugins/bundleSize.js +21 -0
- package/rollup/plugins/{sitevision-client.js → sitevisionClient.js} +2 -2
- package/rollup/plugins/{sitevision-server.js → sitevisionServer.js} +2 -2
- package/rollup/server.js +2 -3
- package/rollup/api/getFilesizePlugin.js +0 -5
- package/rollup/utils/generateBanner.js +0 -9
package/LICENSE.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(c) Copyright 2021 Soleil AB, all rights reserved.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soleil-se/build-app",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"bin": {
|
|
5
5
|
"build-app": "./bin/index.js",
|
|
6
6
|
"sv-app-build": "./bin/index.js"
|
|
@@ -14,41 +14,42 @@
|
|
|
14
14
|
},
|
|
15
15
|
"homepage": "https://docs.soleil.se/build/app",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@babel/core": "7.
|
|
17
|
+
"@babel/core": "7.17.5",
|
|
18
18
|
"@babel/preset-env": "7.16.11",
|
|
19
19
|
"@rollup/plugin-alias": "3.1.9",
|
|
20
|
-
"@rollup/plugin-babel": "5.3.
|
|
21
|
-
"@rollup/plugin-commonjs": "21.0.
|
|
20
|
+
"@rollup/plugin-babel": "5.3.1",
|
|
21
|
+
"@rollup/plugin-commonjs": "21.0.2",
|
|
22
22
|
"@rollup/plugin-json": "4.1.0",
|
|
23
23
|
"@rollup/plugin-node-resolve": "13.1.3",
|
|
24
|
-
"@rollup/plugin-replace": "
|
|
24
|
+
"@rollup/plugin-replace": "4.0.0",
|
|
25
25
|
"@soleil-se/build-config": "1.1.1",
|
|
26
26
|
"@soleil-se/build-utils": "1.3.0",
|
|
27
27
|
"archiver": "5.3.0",
|
|
28
|
-
"autoprefixer": "
|
|
29
|
-
"babel-plugin-transform-async-to-promises": "
|
|
28
|
+
"autoprefixer": "10.4.2",
|
|
29
|
+
"babel-plugin-transform-async-to-promises": "0.8.18",
|
|
30
30
|
"chalk": "5.0.0",
|
|
31
|
-
"find-up": "6.
|
|
31
|
+
"find-up": "6.3.0",
|
|
32
32
|
"form-data": "4.0.0",
|
|
33
|
-
"fs-extra": "10.0.
|
|
33
|
+
"fs-extra": "10.0.1",
|
|
34
34
|
"got": "12.0.1",
|
|
35
|
+
"gzip-size": "7.0.0",
|
|
35
36
|
"lodash-es": "4.17.21",
|
|
36
|
-
"postcss": "8.4.
|
|
37
|
-
"postcss-discard-duplicates": "
|
|
38
|
-
"postcss-pxtorem": "
|
|
39
|
-
"
|
|
37
|
+
"postcss": "8.4.7",
|
|
38
|
+
"postcss-discard-duplicates": "5.0.3",
|
|
39
|
+
"postcss-pxtorem": "6.0.0",
|
|
40
|
+
"pretty-bytes": "6.0.0",
|
|
41
|
+
"rollup": "2.68.0",
|
|
40
42
|
"rollup-plugin-cleanup": "3.2.1",
|
|
41
|
-
"rollup-plugin-
|
|
42
|
-
"rollup-plugin-insert": "^1.3.2",
|
|
43
|
+
"rollup-plugin-insert": "1.3.2",
|
|
43
44
|
"rollup-plugin-postcss": "4.0.2",
|
|
44
45
|
"rollup-plugin-string": "3.0.0",
|
|
45
46
|
"rollup-plugin-svelte": "7.1.0",
|
|
46
47
|
"rollup-plugin-terser": "7.0.2",
|
|
47
48
|
"slash": "4.0.0",
|
|
48
|
-
"svelte-preprocess": "4.10.
|
|
49
|
+
"svelte-preprocess": "4.10.4"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
|
-
"svelte": "3.46.
|
|
52
|
+
"svelte": "3.46.4"
|
|
52
53
|
},
|
|
53
54
|
"description": "Script for building WebApps, RESTApps and Widgets with Svelte in Sitevision.",
|
|
54
55
|
"keywords": [
|
|
@@ -5,9 +5,6 @@ import { kebabCase } from 'lodash-es';
|
|
|
5
5
|
|
|
6
6
|
import preprocessOptions from './common/preprocessOptions.js';
|
|
7
7
|
|
|
8
|
-
let svelte;
|
|
9
|
-
let sveltePreprocess;
|
|
10
|
-
|
|
11
8
|
const validClassRegex = /[^a-z0-9\-_]|^[^a-z]+/gi;
|
|
12
9
|
|
|
13
10
|
const hasSvelte = (input) => {
|
|
@@ -22,15 +19,23 @@ const cssHash = ({ hash, css, name }) => {
|
|
|
22
19
|
return `${kebabCase(validClass)}-${hash(css)}`;
|
|
23
20
|
};
|
|
24
21
|
|
|
22
|
+
const getPreprocess = async () => {
|
|
23
|
+
const svelteConfigPath = findUpSync('svelte.config.js');
|
|
24
|
+
if (svelteConfigPath) {
|
|
25
|
+
return import(`file://${svelteConfigPath}`).then((pkg) => pkg.default.preprocess);
|
|
26
|
+
}
|
|
27
|
+
const sveltePreprocess = await import('svelte-preprocess').then((pkg) => pkg.default);
|
|
28
|
+
return sveltePreprocess(preprocessOptions);
|
|
29
|
+
};
|
|
30
|
+
|
|
25
31
|
export default async function getSveltePlugin({
|
|
26
32
|
input, debug = false, emitCss = true, ssr, hydratable = true,
|
|
27
33
|
}) {
|
|
28
34
|
if (hasSvelte(input)) {
|
|
29
|
-
svelte =
|
|
30
|
-
sveltePreprocess = sveltePreprocess || await import('svelte-preprocess').then((pkg) => pkg.default);
|
|
35
|
+
const svelte = await import('rollup-plugin-svelte').then((pkg) => pkg.default);
|
|
31
36
|
|
|
32
37
|
return svelte({
|
|
33
|
-
preprocess:
|
|
38
|
+
preprocess: await getPreprocess(),
|
|
34
39
|
emitCss,
|
|
35
40
|
compilerOptions: {
|
|
36
41
|
generate: ssr ? 'ssr' : 'dom',
|
package/rollup/client.js
CHANGED
|
@@ -3,7 +3,6 @@ import json from '@rollup/plugin-json';
|
|
|
3
3
|
|
|
4
4
|
import fse from 'fs-extra';
|
|
5
5
|
|
|
6
|
-
import generateBanner from './utils/generateBanner.js';
|
|
7
6
|
import moveCss from './utils/moveCss.js';
|
|
8
7
|
import onwarn from './utils/onwarn.js';
|
|
9
8
|
import getSitevisionClientPackages from './utils/getSitevisionClientPackages.js';
|
|
@@ -15,11 +14,12 @@ import getCommonjsPlugin from './api/getCommonjsPlugin.js';
|
|
|
15
14
|
import getNodeResolvePlugin from './api/getNodeResolvePlugin.js';
|
|
16
15
|
import getSveltePlugin from './api/getSveltePlugin.js';
|
|
17
16
|
import getPostcssPlugin from './api/getPostcssPlugin.js';
|
|
18
|
-
import getFilesizePlugin from './api/getFilesizePlugin.js';
|
|
19
17
|
import getTerserPlugin from './api/getTerserPlugin.js';
|
|
20
|
-
import sitevision from './plugins/sitevision-client.js';
|
|
21
18
|
import getInsertPlugin from './api/getInsertPlugin.js';
|
|
22
19
|
|
|
20
|
+
import sitevision from './plugins/sitevisionClient.js';
|
|
21
|
+
import bundleSize from './plugins/bundleSize.js';
|
|
22
|
+
|
|
23
23
|
export default function rollupClient({
|
|
24
24
|
debug,
|
|
25
25
|
globals = {},
|
|
@@ -53,7 +53,7 @@ export default function rollupClient({
|
|
|
53
53
|
getPostcssPlugin({ cssOutput, debug }),
|
|
54
54
|
getBabelClientPlugin(),
|
|
55
55
|
json(),
|
|
56
|
-
|
|
56
|
+
showSize && bundleSize(),
|
|
57
57
|
getTerserPlugin({ debug }),
|
|
58
58
|
];
|
|
59
59
|
|
|
@@ -69,7 +69,6 @@ export default function rollupClient({
|
|
|
69
69
|
bundleCache = cache && bundle.cache;
|
|
70
70
|
await bundle.write({
|
|
71
71
|
file: output,
|
|
72
|
-
banner: debug && generateBanner(),
|
|
73
72
|
globals,
|
|
74
73
|
format: bundled ? 'amd' : 'iife',
|
|
75
74
|
sourcemap: debug ? 'inline' : false,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { basename } from 'path';
|
|
2
|
+
import { gzipSizeSync } from 'gzip-size';
|
|
3
|
+
import prettyBytes from 'pretty-bytes';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
|
|
6
|
+
import { getTimestamp } from '@soleil-se/build-utils/log';
|
|
7
|
+
|
|
8
|
+
export default function bundleSize() {
|
|
9
|
+
return {
|
|
10
|
+
name: 'rollup-plugin-bundle-size',
|
|
11
|
+
generateBundle({ file }, bundle) {
|
|
12
|
+
const asset = basename(file);
|
|
13
|
+
const { code } = bundle[asset];
|
|
14
|
+
|
|
15
|
+
const original = prettyBytes(code.length);
|
|
16
|
+
const gzipped = prettyBytes(gzipSizeSync(code));
|
|
17
|
+
|
|
18
|
+
console.log(getTimestamp(), `${chalk.green('Created bundle')} ${file}: ${chalk.yellow(original)} → ${chalk.greenBright(gzipped)} (gzip)`);
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export default function
|
|
1
|
+
export default function sitevisionClient() {
|
|
2
2
|
const ignored = [];
|
|
3
3
|
|
|
4
4
|
function isSitevisionScope(id) {
|
|
@@ -17,7 +17,7 @@ export default function sitevision() {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
return {
|
|
20
|
-
name: 'sitevision-
|
|
20
|
+
name: 'rollup-plugin-sitevision-client',
|
|
21
21
|
resolveId(importee) {
|
|
22
22
|
if (shouldResolve(importee)) {
|
|
23
23
|
// Should be handled as usual.
|
|
@@ -18,7 +18,7 @@ const sitevisionPackages = [
|
|
|
18
18
|
'cache',
|
|
19
19
|
];
|
|
20
20
|
|
|
21
|
-
export default function
|
|
21
|
+
export default function sitevisionServer() {
|
|
22
22
|
const ignored = [];
|
|
23
23
|
|
|
24
24
|
function startsWithUpperCase(id) {
|
|
@@ -52,7 +52,7 @@ export default function sitevision() {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
return {
|
|
55
|
-
name: 'sitevision-
|
|
55
|
+
name: 'rollup-plugin-sitevision-server',
|
|
56
56
|
resolveId(importee) {
|
|
57
57
|
if (shouldResolve(importee)) {
|
|
58
58
|
// Should be handled as usual.
|
package/rollup/server.js
CHANGED
|
@@ -5,10 +5,8 @@ import cleanup from 'rollup-plugin-cleanup';
|
|
|
5
5
|
|
|
6
6
|
import fse from 'fs-extra';
|
|
7
7
|
|
|
8
|
-
import generateBanner from './utils/generateBanner.js';
|
|
9
8
|
import moveCss from './utils/moveCss.js';
|
|
10
9
|
import onwarn from './utils/onwarn.js';
|
|
11
|
-
import sitevision from './plugins/sitevision-server.js';
|
|
12
10
|
|
|
13
11
|
import { getReplaceServerPlugin } from './api/getReplacePlugin.js';
|
|
14
12
|
import { getAliasServerPlugin } from './api/getAliasPlugin.js';
|
|
@@ -20,6 +18,8 @@ import getSveltePlugin from './api/getSveltePlugin.js';
|
|
|
20
18
|
import getPostcssPlugin from './api/getPostcssPlugin.js';
|
|
21
19
|
import getTerserPlugin from './api/getTerserPlugin.js';
|
|
22
20
|
|
|
21
|
+
import sitevision from './plugins/sitevisionServer.js';
|
|
22
|
+
|
|
23
23
|
export default function rollupServer({
|
|
24
24
|
debug,
|
|
25
25
|
input,
|
|
@@ -62,7 +62,6 @@ export default function rollupServer({
|
|
|
62
62
|
bundleCache = cache && bundle.cache;
|
|
63
63
|
await bundle.write({
|
|
64
64
|
file: output,
|
|
65
|
-
banner: debug && generateBanner(),
|
|
66
65
|
intro: 'var Promise = Promise || { resolve: () => {} };',
|
|
67
66
|
format: 'iife',
|
|
68
67
|
});
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { template } from 'lodash-es';
|
|
2
|
-
import fse from 'fs-extra';
|
|
3
|
-
import config from '@soleil-se/build-config';
|
|
4
|
-
|
|
5
|
-
const { name, version } = fse.readJSONSync(new URL('../../package.json', import.meta.url));
|
|
6
|
-
|
|
7
|
-
export default function generateBanner() {
|
|
8
|
-
return template(config.banner)({ date: new Date(), build: `${name} - ${version}` });
|
|
9
|
-
}
|