chore: apply feedback, improve warnings

This commit is contained in:
Alexandre Bodin 2025-03-20 08:55:54 +01:00
parent 4bd7b4e8f5
commit 6b93a97ac7
5 changed files with 30 additions and 17 deletions

View File

@ -2,6 +2,7 @@
"namedInputs": {
"default": ["{projectRoot}/**/*"],
"production": [
"{workspaceRoot}/rollup.utils.mjs",
"!{projectRoot}/**/*.test.ts",
"!{projectRoot}/**/*.test.js",
"!{projectRoot}/**/*.test.api.js",
@ -12,8 +13,7 @@
"!{projectRoot}/jest.config.front.js",
"!{projectRoot}/tsconfig.eslint.json",
"!{projectRoot}/.eslintignore",
"!{projectRoot}/.eslintrc.js",
"!{projectRoot}/rollup.config.mjs"
"!{projectRoot}/.eslintrc.js"
]
},
"cli": {

View File

@ -330,8 +330,6 @@ class StrapiApp {
try {
const { default: data } = await import(`./translations/${locale}.js`);
console.log(data);
return { data, locale };
} catch {
try {

View File

@ -1,11 +1,7 @@
import { lazy } from 'react';
import { Page } from '../../../../components/PageHelpers';
import { useTypedSelector } from '../../../../core/store/hooks';
// import { EditPage } from './EditPage';
const EditPage = lazy(() => import('./EditPage').then((module) => ({ default: module.EditPage })));
import { EditPage } from './EditPage';
const ProtectedCreatePage = () => {
const permissions = useTypedSelector(

View File

@ -22,13 +22,5 @@ export default defineConfig([
test: './admin/tests/index.ts',
},
outDir: './dist/admin',
onwarn(warning, warn) {
// Suppress the "default is never used" warning for React
if (warning.code === 'UNUSED_EXTERNAL_IMPORT' && warning.exporter === 'react') {
return;
}
warn(warning); // Log other warnings
},
}),
]);

View File

@ -42,6 +42,14 @@ const basePlugins = () => [
dynamicImportVars({}),
];
const isInput = (id, input) => {
if (typeof input === 'string') {
return id.includes(path.resolve(input));
}
return Object.values(input).some((i) => id.includes(path.resolve(i)));
};
const baseConfig = (opts = {}) => {
const { rootDir, outDir = './dist', input = './src/index.ts', ...rest } = opts;
@ -50,6 +58,25 @@ const baseConfig = (opts = {}) => {
external: isExernal,
output: baseOutput({ outDir, rootDir }),
plugins: basePlugins(),
onwarn(warning, warn) {
if (warning.code === 'MIXED_EXPORTS') {
// json files are always mixed exports
if (warning?.id?.endsWith('.json')) {
return;
}
// we only care about mixed exports in our input files
if (warning.id && !isInput(warning.id, input)) {
return;
}
}
if (warning.code === 'UNUSED_EXTERNAL_IMPORT' && warning.exporter === 'react') {
return;
}
warn(warning);
},
...rest,
});
};