Przeglądaj źródła

Improved the snippet adapter.

Kamil Piechaczek 5 lat temu
rodzic
commit
49fa2e44ed
2 zmienionych plików z 19 dodań i 2 usunięć
  1. 0 1
      package.json
  2. 19 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",

+ 19 - 1
scripts/docs/snippetadapter.js

@@ -393,7 +393,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: {
@@ -471,6 +474,21 @@ 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 packagesDirectory = path.resolve( __dirname, '..', '..', 'packages' );
+
+	return fs.readdirSync( packagesDirectory )
+		.map( directory => path.join( packagesDirectory, directory, 'node_modules' ) );
+}
+
 /**
  * Reads the snippet's configuration.
  *