mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
3d05acf313
* ⚡ Introduce a framework for expression extension * 💡 Add some inline comments * ⚡ Introduce hash alias for encrypt * ⚡ Introduce a manual granular level approach to shadowing/overrideing extensions * 🔥 Cleanup comments * ⚡ Introduce a basic method of extension for native functions * ⚡ Add length to StringExtension * ⚡ Add number type to extension return types * ⚡ Temporarily introduce DateTime with extension * ⚡ Cleanup comments * ⚡ Organize imports * ♻️ Fix up some typings * ⚡ Fix typings * ♻️ Remove unnecessary resolve of expression * ⚡ Extensions Improvement * ♻️ Refactor EXPRESSION_EXTENSION_METHODS * ♻️ Refactor EXPRESSION_EXTENSION_METHODS * ♻️ Update extraArgs types * ♻️ Fix tests * ♻️ Fix bind type issue * ♻️ Fixing duration type issue * ♻️ Refactor to allow overrides on native methods * ♻️ Temporarily remove Date Extensions to pass tests * feat(dt-functions): introduce date expression extensions (#4045) * 🎉 Add Date Extensions into the mix * ✨ Introduce additional date extension methods * ✅ Add Date Expression Extension tests * 🔧 Add ability to debug tests * ♻️ Refactor extension for native types * 🔥 Move sayHi method to String Extension class * ♻️ Update scope when binding member methods * ✅ Add String Extension tests * feat(dt-functions): introduce array expression extensions (#4044) * ✨ Introduce Array Extensions * ✅ Add Array Expression tests * feat(dt-functions): introduce number expression extensions (#4046) * 🎉 Introduce Number Extensions * ⚡ Support more shared extensions * ⚡ Improve handling of name collision * ✅ Update tests * Fixed up tests * 🔥 Remove remove markdown * :recylce: Replace remove-markdown dependencies with implementation * ♻️ Replace remove-markdown dependencies with implementation * ✅ Update tests * ♻️ Fix scoping and cleanup * ♻️ Update comments and errors * ♻️ Fix linting errors * ➖ Remove unused dependencies * fix: expression extension not working with multiple extensions * refactor: change extension transform to be more efficient * test: update most test to work with new extend function * fix: update and fix type error in config * refactor: replace babel with recast * feat: add hashing functions to string extension * fix: removed export * test: add extension parser and transform tests * fix: vite tests breaking * refactor: remove commented out code * fix: parse dates passed from $json in extend function * refactor: review feedback changes for date extensions * refactor: review feedback changes for number extensions * fix: date extension beginningOf test * fix: broken build from merge * fix: another merge issue * refactor: address review feedback (remove ignores) * feat: new extension functions and tests * feat: non-dot notation functions * test: most of the other tests * fix: toSentenceCase for node versions below 16.6 * feat: add $if and $not expression extensions * Fix test to work on every timezone * lint: fix remaining lint issues Co-authored-by: Csaba Tuncsik <csaba@n8n.io> Co-authored-by: Omar Ajoue <krynble@gmail.com>
125 lines
3 KiB
TypeScript
125 lines
3 KiB
TypeScript
import vue from '@vitejs/plugin-vue2';
|
|
import { createHtmlPlugin } from 'vite-plugin-html';
|
|
import legacy from '@vitejs/plugin-legacy';
|
|
import monacoEditorPlugin from 'vite-plugin-monaco-editor';
|
|
import path, { resolve } from 'path';
|
|
import { defineConfig, mergeConfig, PluginOption } from 'vite';
|
|
import { defineConfig as defineVitestConfig } from 'vitest/config';
|
|
import packageJSON from './package.json';
|
|
|
|
const vendorChunks = ['vue', 'vue-router'];
|
|
const ignoreChunks = [
|
|
'vue2-boring-avatars',
|
|
'vue-template-compiler',
|
|
'jquery',
|
|
'@fontsource/open-sans',
|
|
];
|
|
|
|
const isScopedPackageToIgnore = (str: string) => /@codemirror\//.test(str);
|
|
|
|
function renderChunks() {
|
|
const { dependencies } = packageJSON;
|
|
const chunks: Record<string, string[]> = {};
|
|
|
|
Object.keys(dependencies).forEach((key) => {
|
|
if ([...vendorChunks, ...ignoreChunks].includes(key)) {
|
|
return;
|
|
}
|
|
|
|
if (isScopedPackageToIgnore(key)) return;
|
|
|
|
chunks[key] = [key];
|
|
});
|
|
|
|
return chunks;
|
|
}
|
|
|
|
const publicPath = process.env.VUE_APP_PUBLIC_PATH || '/';
|
|
|
|
const lodashAliases = ['orderBy', 'camelCase', 'cloneDeep', 'isEqual', 'startCase'].map((name) => ({
|
|
find: new RegExp(`^lodash.${name}$`, 'i'),
|
|
replacement: require.resolve(`lodash-es/${name}`),
|
|
}));
|
|
|
|
export default mergeConfig(
|
|
defineConfig({
|
|
define: {
|
|
// This causes test to fail but is required for actually running it
|
|
...(process.env.NODE_ENV !== 'test' ? { global: 'globalThis' } : {}),
|
|
},
|
|
plugins: [
|
|
legacy({
|
|
targets: ['defaults', 'not IE 11'],
|
|
}),
|
|
vue(),
|
|
...(createHtmlPlugin({
|
|
inject: {
|
|
data: {
|
|
BASE_PATH: publicPath,
|
|
},
|
|
},
|
|
}) as PluginOption[]),
|
|
monacoEditorPlugin({
|
|
publicPath: 'assets/monaco-editor',
|
|
customDistPath: (root: string, buildOutDir: string, base: string) =>
|
|
`${root}/${buildOutDir}/assets/monaco-editor`,
|
|
}) as PluginOption,
|
|
],
|
|
resolve: {
|
|
alias: [
|
|
{ find: '@', replacement: resolve(__dirname, 'src') },
|
|
{ find: 'stream', replacement: '' },
|
|
{
|
|
find: /^n8n-design-system\//,
|
|
replacement: resolve(__dirname, '..', 'design-system', 'src') + '/',
|
|
},
|
|
...lodashAliases,
|
|
{
|
|
find: /^lodash.(.+)$/,
|
|
replacement: 'lodash-es/$1',
|
|
},
|
|
{
|
|
find: 'vue2-boring-avatars',
|
|
replacement: require.resolve('vue2-boring-avatars'),
|
|
},
|
|
{
|
|
find: /element-ui\/(packages|lib)\/button$/,
|
|
replacement: path.resolve(
|
|
__dirname,
|
|
'..',
|
|
'design-system/src/components/N8nButton/overrides/ElButton.ts',
|
|
),
|
|
},
|
|
],
|
|
},
|
|
base: publicPath,
|
|
envPrefix: 'VUE_APP',
|
|
css: {
|
|
preprocessorOptions: {
|
|
scss: {
|
|
additionalData: '\n@use "@/n8n-theme-variables.scss" as *;\n',
|
|
},
|
|
},
|
|
},
|
|
build: {
|
|
assetsInlineLimit: 0,
|
|
sourcemap: false,
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks: {
|
|
vendor: vendorChunks,
|
|
...renderChunks(),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}),
|
|
defineVitestConfig({
|
|
test: {
|
|
globals: true,
|
|
environment: 'jsdom',
|
|
setupFiles: ['./src/__tests__/setup.ts'],
|
|
},
|
|
}),
|
|
);
|