Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat dependencies in the dist folder as production dependencies. #964

Merged
merged 5 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type { Plugin } from 'rollup';
import { removeWhitespace } from '../utils';

const TYPINGS = removeWhitespace( `
import type { Translations } from 'ckeditor5';
import type { Translations } from '@ckeditor/ckeditor5-utils';
pomek marked this conversation as resolved.
Show resolved Hide resolved

declare const translations: Translations;
export default translations;
Expand Down
27 changes: 24 additions & 3 deletions packages/ckeditor5-dev-dependency-checker/lib/checkdependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async function checkDependenciesInPackage( packagePath, options ) {
'**/*.ts': depCheck.parser.typescript,
'**/*.vue': depCheck.parser.vue
},
ignorePatterns: [ 'docs', 'build', 'dist' ],
ignorePatterns: [ 'docs', 'build', 'dist/browser' ],
ignoreMatches: [ 'eslint*', 'webpack*', 'husky', 'lint-staged' ]
};

Expand Down Expand Up @@ -381,9 +381,30 @@ async function isDevDependency( packageName, absolutePaths ) {
return true;
}

/**
* These folders contain code that will be shipped to npm and run in the final projects.
* This means that all dependencies used in these folders are production dependencies.
*/
const foldersContainingProductionCode = [
/**
* These folders contain the source code of the packages.
*/
/[/\\]src[/\\]/,
/[/\\]theme[/\\]/,

/**
* This folder contains the compiled code of the packages. Most of this code is the same
* as the source, but during the build process some of the imports are replaced with those
* compatible with the "new installation methods", which may use different dependencies.
*
* For example, the `ckeditor5/src/core.js` import is replaced with `@ckeditor/ckeditor5-core/dist/index.js`.
* ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^
*/
/[/\\]dist[/\\]/
filipsobol marked this conversation as resolved.
Show resolved Hide resolved
];

for ( const absolutePath of absolutePaths ) {
// Only imports in files in src/ or theme/ could be non dev dependency.
if ( !absolutePath.match( /[/\\](src|theme)[/\\]/ ) ) {
if ( !foldersContainingProductionCode.some( folder => absolutePath.match( folder ) ) ) {
continue;
}

Expand Down