Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ComLock committed Feb 29, 2024
1 parent f50e7bf commit d7cf7ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 107 deletions.
20 changes: 8 additions & 12 deletions src/main/resources/guillotine/getSiteConfigFromSite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,14 @@ export const getSiteConfigFromSite = ({
}
) => {
// Code courtesy of PVMerlo at Enonic Discuss - https://discuss.enonic.com/u/PVMerlo
if (site) {
if (site.data) {
if (site.data.siteConfig) {
const siteConfigs = forceArray(site.data.siteConfig);
let siteConfig: Partial<typeof siteConfigs[0]> = {};
siteConfigs.forEach((cfg) => {
if (cfg.applicationKey == applicationKey) {
siteConfig = cfg;
}
});
return siteConfig.config;
if (site?.data?.siteConfig) {
const siteConfigs = forceArray(site.data.siteConfig);
let siteConfig: Partial<typeof siteConfigs[0]> = {};
siteConfigs.forEach((cfg) => {
if (cfg.applicationKey == applicationKey) {
siteConfig = cfg;
}
}
});
return siteConfig.config;
}
};
95 changes: 0 additions & 95 deletions tsup/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import type { Options } from '.';


import { globSync } from 'glob';
// import { polyfillNode } from 'esbuild-plugin-polyfill-node';
// import { print } from 'q-i';
import {DIR_SRC} from './constants';


Expand All @@ -16,89 +14,17 @@ export default function buildServerConfig(): Options {
ignore: globSync(`${DIR_SRC}/**/*.d.ts`)
}
).map(s => s.replaceAll('\\', '/'));
// print(FILES_SERVER, { maxItems: Infinity });

return {
bundle: true, // Needed to bundle @enonic/js-utils
dts: false, // d.ts files are use useless at runtime
entry: FILES_SERVER,
// env: {
// BROWSER_SYNC_PORT: '3000',
// },
esbuildOptions(options, context) {
// options.alias = {
// 'alias': './src/main/resources/lib/filename.js'
// };

// Some node modules might need globalThis
// options.banner = {
// js: `const globalThis = (1, eval)('this');` // buffer polyfill needs this
// };

// If you have libs with chunks, use this to avoid collisions
options.chunkNames = '_chunks/[name]-[hash]';

options.mainFields = ['module', 'main'];
},
esbuildPlugins: [
// Some node modules might need parts of Node polyfilled:
// polyfillNode({
// globals: {
// buffer: false,
// process: false
// },
// polyfills: {
// _stream_duplex: false,
// _stream_passthrough: false,
// _stream_readable: false,
// _stream_transform: false,
// _stream_writable: false,
// assert: false,
// 'assert/strict': false,
// async_hooks: false,
// buffer: false,
// child_process: false,
// cluster: false,
// console: false,
// constants: false,
// crypto: false,
// dgram: false,
// diagnostics_channel: false,
// dns: false,
// domain: false,
// events: false,
// fs: false,
// 'fs/promises': false,
// http: false,
// http2: false,
// https: false,
// module: false,
// net: false,
// os: false,
// path: false,
// perf_hooks: false,
// process: false, //"empty",
// punycode: false,
// querystring: false,
// readline: false,
// repl: false,
// stream: false,
// string_decoder: false,
// sys: false,
// timers: false,
// 'timers/promises': false,
// tls: false,
// tty: false,
// url: false,
// util: false, // true,
// v8: false,
// vm: false,
// wasi: false,
// worker_threads: false,
// zlib: false,
// }
// }) // ReferenceError: "navigator" is not defined
],
external: [
/^\/lib\/app-sitemapxml/,
'/lib/cache',
Expand All @@ -118,27 +44,6 @@ export default function buildServerConfig(): Options {
'/lib/xslt',
],
format: 'cjs',
inject: [
// Injects makes it possible to use some functionality in any file :)
// However it also makes every file larger, unless splitting: true
// If for some reason you cannot use code splitting, it is better
// to import a polyfill only in the entries that needs it.
// Code-js polyfills share code, so together they don't add the sum of all the polyfills.
// For example injecting both number/is-finite and is-integer only adds 60K, not 108K

// Here are some things Nashorn doesn't support, comment them in to inject them:
// 'node_modules/core-js/stable/array/flat.js', // 69K (18K) minified
// 'node_modules/core-js/stable/array/includes.js', // 60K (15K)
// 'node_modules/core-js/stable/math/trunc.js', // 53K (14K)
// 'node_modules/core-js/stable/number/is-finite.js', // 54K (14K)
// 'node_modules/core-js/stable/number/is-integer.js', // 54K (14K)
// 'node_modules/core-js/stable/parse-float.js', // 59K (15K)
// 'node_modules/core-js/stable/reflect/index.js', // 88K (22K)
// 'node_modules/core-js/stable/string/pad-start.js',

// TIP: I used this command to find sizes
// npm --silent run clean && npm --silent run build:server; ls -lh build/resources/main/empty.js; npm --silent run clean && npm --silent run build:server -- --minify; ls -lh build/resources/main/empty.js
],
minify: false, // Minifying server files makes debugging harder

// TIP: Command to check if there are any bad requires left behind
Expand Down

0 comments on commit d7cf7ec

Please sign in to comment.