浏览代码

Merge pull request #8215 from ckeditor/i/7916

Internal: The snippet adapter will be searching for proper packages' dependencies. Closes #7916.
Kamil Piechaczek 5 年之前
父节点
当前提交
eb73de3f46
共有 2 个文件被更改,包括 23 次插入2 次删除
  1. 0 1
      package.json
  2. 23 1
      scripts/docs/snippetadapter.js

+ 0 - 1
package.json

@@ -100,7 +100,6 @@
     "http-server": "^0.12.3",
     "husky": "^4.2.5",
     "lint-staged": "^10.2.6",
-    "marked": "^1.1.1",
     "mini-css-extract-plugin": "^0.9.0",
     "minimatch": "^3.0.4",
     "mkdirp": "^1.0.4",

+ 23 - 1
scripts/docs/snippetadapter.js

@@ -14,6 +14,7 @@ const CKEditorWebpackPlugin = require( '@ckeditor/ckeditor5-dev-webpack-plugin'
 const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
 const TerserPlugin = require( 'terser-webpack-plugin' );
 const ProgressBarPlugin = require( 'progress-bar-webpack-plugin' );
+const glob = require( 'glob' );
 
 const DEFAULT_LANGUAGE = 'en';
 const MULTI_LANGUAGE = 'multi-language';
@@ -393,7 +394,10 @@ function getWebpackConfig( snippets, config ) {
 		// Configure the paths so building CKEditor 5 snippets work even if the script
 		// is triggered from a directory outside ckeditor5 (e.g. multi-project case).
 		resolve: {
-			modules: getModuleResolvePaths()
+			modules: [
+				...getPackageDependenciesPaths(),
+				...getModuleResolvePaths()
+			]
 		},
 
 		resolveLoader: {
@@ -472,6 +476,24 @@ function getModuleResolvePaths() {
 }
 
 /**
+ * Returns an array that contains paths to packages' dependencies.
+ * The snippet adapter should use packages' dependencies instead of the documentation builder dependencies.
+ *
+ * See #7916.
+ *
+ * @returns {Array.<String>}
+ */
+function getPackageDependenciesPaths() {
+	const globOptions = {
+		cwd: path.resolve( __dirname, '..', '..' ),
+		absolute: true
+	};
+
+	return glob.sync( 'packages/*/node_modules', globOptions )
+		.concat( glob.sync( 'external/*/packages/*/node_modules', globOptions ) );
+}
+
+/**
  * Reads the snippet's configuration.
  *
  * @param {String} snippetSourcePath An absolute path to the file.