Plugins: add a bundle plugins folder (#20850)
This commit is contained in:
@@ -67,6 +67,7 @@
|
||||
"execa": "^1.0.0",
|
||||
"expect-puppeteer": "4.1.1",
|
||||
"file-loader": "^4.0.0",
|
||||
"fork-ts-checker-webpack-plugin": "1.0.0",
|
||||
"fs-extra": "^8.1.0",
|
||||
"globby": "^10.0.1",
|
||||
"html-loader": "0.5.5",
|
||||
|
||||
@@ -18,6 +18,7 @@ import { githubPublishTask } from './tasks/plugin.utils';
|
||||
import { ciBuildPluginTask, ciBuildPluginDocsTask, ciPackagePluginTask, ciPluginReportTask } from './tasks/plugin.ci';
|
||||
import { buildPackageTask } from './tasks/package.build';
|
||||
import { pluginCreateTask } from './tasks/plugin.create';
|
||||
import { bundleManagedTask } from './tasks/plugin/bundle.managed';
|
||||
|
||||
export const run = (includeInternalScripts = false) => {
|
||||
if (includeInternalScripts) {
|
||||
@@ -195,6 +196,13 @@ export const run = (includeInternalScripts = false) => {
|
||||
});
|
||||
});
|
||||
|
||||
program
|
||||
.command('plugin:bundle-managed')
|
||||
.description('Builds managed plugins')
|
||||
.action(async cmd => {
|
||||
await execTask(bundleManagedTask)({});
|
||||
});
|
||||
|
||||
program
|
||||
.command('plugin:github-publish')
|
||||
.option('--dryrun', 'Do a dry run only', false)
|
||||
|
||||
@@ -13,6 +13,7 @@ describe('Manifest', () => {
|
||||
"manifest.ts",
|
||||
"nodeVersionChecker.ts",
|
||||
"package.build.ts",
|
||||
"plugin/bundle.managed.ts",
|
||||
"plugin/bundle.ts",
|
||||
"plugin/create.ts",
|
||||
"plugin/tests.ts",
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import { Task, TaskRunner } from '../task';
|
||||
import { restoreCwd } from '../../utils/cwd';
|
||||
import execa = require('execa');
|
||||
const fs = require('fs');
|
||||
const util = require('util');
|
||||
|
||||
const readdirPromise = util.promisify(fs.readdir);
|
||||
|
||||
interface BundeManagedOptions {}
|
||||
|
||||
const MANAGED_PLUGINS_PATH = `${process.cwd()}/plugins-bundled`;
|
||||
const MANAGED_PLUGINS_SCOPES = ['internal', 'external'];
|
||||
|
||||
const bundleManagedPluginsRunner: TaskRunner<BundeManagedOptions> = async () => {
|
||||
await Promise.all(
|
||||
MANAGED_PLUGINS_SCOPES.map(async scope => {
|
||||
try {
|
||||
const plugins = await readdirPromise(`${MANAGED_PLUGINS_PATH}/${scope}`);
|
||||
if (plugins.length > 0) {
|
||||
for (const plugin of plugins) {
|
||||
process.chdir(`${MANAGED_PLUGINS_PATH}/${scope}/${plugin}`);
|
||||
try {
|
||||
await execa('yarn', ['dev']);
|
||||
console.log(`[${scope}]: ${plugin} bundled`);
|
||||
} catch (e) {
|
||||
console.log(e.stdout);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
})
|
||||
);
|
||||
restoreCwd();
|
||||
};
|
||||
|
||||
export const bundleManagedTask = new Task<BundeManagedOptions>('Bundle managed plugins', bundleManagedPluginsRunner);
|
||||
@@ -7,6 +7,7 @@ const TerserPlugin = require('terser-webpack-plugin');
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
||||
|
||||
const readdirPromise = util.promisify(fs.readdir);
|
||||
const accessPromise = util.promisify(fs.access);
|
||||
@@ -123,6 +124,11 @@ const getCommonPlugins = (options: WebpackConfigurationOptions) => {
|
||||
],
|
||||
},
|
||||
]),
|
||||
new ForkTsCheckerWebpackPlugin({
|
||||
tsconfig: path.join(process.cwd(), 'tsconfig.json'),
|
||||
// Only report problems in detected in plugin's code
|
||||
reportFiles: ['**/*.{ts,tsx}'],
|
||||
}),
|
||||
];
|
||||
};
|
||||
|
||||
@@ -205,7 +211,10 @@ const getBaseWebpackConfig: WebpackConfigurationGetter = async options => {
|
||||
},
|
||||
{
|
||||
loader: 'ts-loader',
|
||||
options: { onlyCompileBundledFiles: true },
|
||||
options: {
|
||||
onlyCompileBundledFiles: true,
|
||||
transpileOnly: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
exclude: /(node_modules)/,
|
||||
|
||||
Reference in New Issue
Block a user