mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[build] Removes commonjs transforms (#66506)
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co> Co-authored-by: spalger <spalger@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
d6ef808025
commit
c675301a87
16 changed files with 70 additions and 43 deletions
|
@ -121,6 +121,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.9.0",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.9.0",
|
||||
"@babel/register": "^7.9.0",
|
||||
"@elastic/apm-rum": "^5.1.1",
|
||||
"@elastic/charts": "19.2.0",
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.8.3",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.9.0",
|
||||
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.9.0",
|
||||
"@babel/preset-env": "^7.9.0",
|
||||
"@babel/preset-react": "^7.9.1",
|
||||
"@babel/preset-typescript": "^7.9.0",
|
||||
|
|
|
@ -33,8 +33,6 @@ module.exports = () => {
|
|||
require('./common_preset'),
|
||||
],
|
||||
plugins: [
|
||||
require.resolve('@babel/plugin-transform-modules-commonjs'),
|
||||
require.resolve('@babel/plugin-syntax-dynamic-import'),
|
||||
[
|
||||
require.resolve('babel-plugin-styled-components'),
|
||||
{
|
||||
|
|
|
@ -17,6 +17,11 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
export { I18nProvider, I18nServiceType } from './provider';
|
||||
export { I18nProvider } from './provider';
|
||||
|
||||
export { i18nFilter } from './filter';
|
||||
export { i18nDirective } from './directive';
|
||||
|
||||
// re-export types: https://github.com/babel/babel-loader/issues/603
|
||||
import { I18nServiceType as _I18nServiceType } from './provider';
|
||||
export type I18nServiceType = _I18nServiceType;
|
||||
|
|
|
@ -17,9 +17,11 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { InjectedIntl as _InjectedIntl } from 'react-intl';
|
||||
export type InjectedIntl = _InjectedIntl;
|
||||
|
||||
export {
|
||||
intlShape,
|
||||
InjectedIntl,
|
||||
FormattedDate,
|
||||
FormattedTime,
|
||||
FormattedRelative,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"presets": ["@kbn/babel-preset/webpack_preset"],
|
||||
"plugins": [
|
||||
"@babel/plugin-transform-modules-commonjs",
|
||||
["@babel/plugin-transform-runtime", {
|
||||
"regenerator": true
|
||||
}]
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
"devDependencies": {
|
||||
"@babel/cli": "^7.8.4",
|
||||
"@babel/core": "^7.9.0",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.9.0",
|
||||
"@babel/plugin-transform-runtime": "^7.9.0",
|
||||
"@kbn/babel-preset": "1.0.0",
|
||||
"@kbn/dev-utils": "1.0.0",
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -34,6 +34,19 @@ const MOCK_REPO_DIR = Path.resolve(TMP_DIR, 'mock_repo');
|
|||
|
||||
expect.addSnapshotSerializer(createAbsolutePathSerializer(REPO_ROOT));
|
||||
|
||||
const log = new ToolingLog({
|
||||
level: 'error',
|
||||
writeTo: {
|
||||
write(chunk) {
|
||||
if (chunk.endsWith('\n')) {
|
||||
chunk = chunk.slice(0, -1);
|
||||
}
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(chunk);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
beforeAll(async () => {
|
||||
await del(TMP_DIR);
|
||||
await cpy('**/*', MOCK_REPO_DIR, {
|
||||
|
@ -52,23 +65,11 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
|
|||
repoRoot: MOCK_REPO_DIR,
|
||||
pluginScanDirs: [Path.resolve(MOCK_REPO_DIR, 'plugins')],
|
||||
maxWorkerCount: 1,
|
||||
dist: true,
|
||||
dist: false,
|
||||
});
|
||||
|
||||
expect(config).toMatchSnapshot('OptimizerConfig');
|
||||
|
||||
const log = new ToolingLog({
|
||||
level: 'error',
|
||||
writeTo: {
|
||||
write(chunk) {
|
||||
if (chunk.endsWith('\n')) {
|
||||
chunk = chunk.slice(0, -1);
|
||||
}
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(chunk);
|
||||
},
|
||||
},
|
||||
});
|
||||
const msgs = await runOptimizer(config)
|
||||
.pipe(logOptimizerState(log, config), toArray())
|
||||
.toPromise();
|
||||
|
@ -125,13 +126,6 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
|
|||
);
|
||||
assert('produce zero unexpected states', otherStates.length === 0, otherStates);
|
||||
|
||||
expectFileMatchesSnapshotWithCompression('plugins/foo/target/public/foo.plugin.js', 'foo bundle');
|
||||
expectFileMatchesSnapshotWithCompression(
|
||||
'plugins/foo/target/public/1.plugin.js',
|
||||
'1 async bundle'
|
||||
);
|
||||
expectFileMatchesSnapshotWithCompression('plugins/bar/target/public/bar.plugin.js', 'bar bundle');
|
||||
|
||||
const foo = config.bundles.find(b => b.id === 'foo')!;
|
||||
expect(foo).toBeTruthy();
|
||||
foo.cache.refresh();
|
||||
|
@ -174,7 +168,7 @@ it('uses cache on second run and exist cleanly', async () => {
|
|||
repoRoot: MOCK_REPO_DIR,
|
||||
pluginScanDirs: [Path.resolve(MOCK_REPO_DIR, 'plugins')],
|
||||
maxWorkerCount: 1,
|
||||
dist: true,
|
||||
dist: false,
|
||||
});
|
||||
|
||||
const msgs = await runOptimizer(config)
|
||||
|
@ -200,6 +194,26 @@ it('uses cache on second run and exist cleanly', async () => {
|
|||
`);
|
||||
});
|
||||
|
||||
it('prepares assets for distribution', async () => {
|
||||
const config = OptimizerConfig.create({
|
||||
repoRoot: MOCK_REPO_DIR,
|
||||
pluginScanDirs: [Path.resolve(MOCK_REPO_DIR, 'plugins')],
|
||||
maxWorkerCount: 1,
|
||||
dist: true,
|
||||
});
|
||||
|
||||
await runOptimizer(config)
|
||||
.pipe(logOptimizerState(log, config), toArray())
|
||||
.toPromise();
|
||||
|
||||
expectFileMatchesSnapshotWithCompression('plugins/foo/target/public/foo.plugin.js', 'foo bundle');
|
||||
expectFileMatchesSnapshotWithCompression(
|
||||
'plugins/foo/target/public/1.plugin.js',
|
||||
'1 async bundle'
|
||||
);
|
||||
expectFileMatchesSnapshotWithCompression('plugins/bar/target/public/bar.plugin.js', 'bar bundle');
|
||||
});
|
||||
|
||||
/**
|
||||
* Verifies that the file matches the expected output and has matching compressed variants.
|
||||
*/
|
||||
|
|
|
@ -23,6 +23,7 @@ import 'angular-sanitize';
|
|||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import routes from 'ui/routes';
|
||||
import { capabilities } from 'ui/capabilities';
|
||||
import { docTitle } from 'ui/doc_title';
|
||||
import { fatalError, toastNotifications } from 'ui/notify';
|
||||
|
@ -62,9 +63,9 @@ document.title = 'Timelion - Kibana';
|
|||
|
||||
const app = require('ui/modules').get('apps/timelion', ['i18n', 'ngSanitize']);
|
||||
|
||||
require('ui/routes').enable();
|
||||
routes.enable();
|
||||
|
||||
require('ui/routes').when('/:id?', {
|
||||
routes.when('/:id?', {
|
||||
template: rootTemplate,
|
||||
reloadOnSearch: false,
|
||||
k7Breadcrumbs: ($injector, $route) =>
|
||||
|
|
|
@ -49,6 +49,10 @@ const STATS_WARNINGS_FILTER = new RegExp(
|
|||
);
|
||||
const IS_CODE_COVERAGE = !!process.env.CODE_COVERAGE;
|
||||
|
||||
const LEGACY_PRESETS = {
|
||||
plugins: [require.resolve('@babel/plugin-transform-modules-commonjs')],
|
||||
};
|
||||
|
||||
function recursiveIssuer(m) {
|
||||
if (m.issuer) {
|
||||
return recursiveIssuer(m.issuer);
|
||||
|
@ -123,7 +127,7 @@ export default class BaseOptimizer {
|
|||
}
|
||||
|
||||
warmupThreadLoaderPool() {
|
||||
const baseModules = ['babel-loader', BABEL_PRESET_PATH];
|
||||
const baseModules = ['babel-loader', BABEL_PRESET_PATH, LEGACY_PRESETS];
|
||||
|
||||
threadLoader.warmup(
|
||||
// pool options, like passed to loader options
|
||||
|
@ -522,6 +526,8 @@ export default class BaseOptimizer {
|
|||
}
|
||||
|
||||
getPresets() {
|
||||
return IS_CODE_COVERAGE ? [ISTANBUL_PRESET_PATH, BABEL_PRESET_PATH] : [BABEL_PRESET_PATH];
|
||||
return IS_CODE_COVERAGE
|
||||
? [ISTANBUL_PRESET_PATH, BABEL_PRESET_PATH, LEGACY_PRESETS]
|
||||
: [BABEL_PRESET_PATH, LEGACY_PRESETS];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ function normalizePath(path) {
|
|||
return path.replace(/[\\\/]+/g, '/');
|
||||
}
|
||||
|
||||
export default function() {
|
||||
module.exports = function() {
|
||||
if (!module.id.includes('?')) {
|
||||
throw new Error('create_ui_exports_module loaded without JSON args in module.id');
|
||||
}
|
||||
|
@ -37,4 +37,4 @@ export default function() {
|
|||
return {
|
||||
code: `${comment}\n${requires}\n`,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
|
@ -44,6 +44,8 @@ export { APMOSSPluginSetup } from './plugin';
|
|||
|
||||
export { apmIndexPattern };
|
||||
|
||||
export { APM_STATIC_INDEX_PATTERN_ID } from '../common/index_pattern_constants';
|
||||
|
||||
export {
|
||||
createNodeAgentInstructions,
|
||||
createDjangoAgentInstructions,
|
||||
|
|
|
@ -36,9 +36,7 @@ import {
|
|||
} from './context/query';
|
||||
import { callAfterBindingsWorkaround } from './context/helpers/call_after_bindings_workaround';
|
||||
|
||||
const module = getAngularModule();
|
||||
|
||||
module.directive('contextApp', function ContextApp() {
|
||||
getAngularModule().directive('contextApp', function ContextApp() {
|
||||
return {
|
||||
bindToController: true,
|
||||
controller: callAfterBindingsWorkaround(ContextAppController),
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
import { SavedObjectsErrorHelpers } from '../../../../../../src/core/server';
|
||||
import { apmIndexPattern } from '../../../../../../src/plugins/apm_oss/server';
|
||||
import { APM_STATIC_INDEX_PATTERN_ID } from '../../../../../../src/plugins/apm_oss/public';
|
||||
import { APM_STATIC_INDEX_PATTERN_ID } from '../../../../../../src/plugins/apm_oss/server';
|
||||
import { hasHistoricalAgentData } from '../services/get_services/has_historical_agent_data';
|
||||
import { Setup } from '../helpers/setup_request';
|
||||
import { APMRequestHandlerContext } from '../../routes/typings';
|
||||
|
|
|
@ -468,7 +468,7 @@
|
|||
dependencies:
|
||||
"@babel/helper-plugin-utils" "^7.0.0"
|
||||
|
||||
"@babel/plugin-syntax-dynamic-import@^7.2.0", "@babel/plugin-syntax-dynamic-import@^7.8.0", "@babel/plugin-syntax-dynamic-import@^7.8.3":
|
||||
"@babel/plugin-syntax-dynamic-import@^7.2.0", "@babel/plugin-syntax-dynamic-import@^7.8.0":
|
||||
version "7.8.3"
|
||||
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.8.3.tgz#62bf98b2da3cd21d626154fc96ee5b3cb68eacb3"
|
||||
integrity sha512-5gdGbFon+PszYzqs83S3E5mpi7/y/8M9eC90MRTZfduQOYW76ig6SOSPNe41IG5LoP3FGBn2N0RjVDSQiS94kQ==
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue