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

[Maps] Test worker loading #4

Closed
Show file tree
Hide file tree
Changes from all 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 @@ -66,10 +66,38 @@ export const CleanClientModulesOnDLLTask = {
// side code entries that were provided
const serverDependencies = await getDependencies(baseDir, serverEntries);

// This fulfill a particular exceptional case where
// we need to keep loading a file from a node_module
// only used in the front-end like we do when using the file-loader
// in https://github.com/elastic/kibana/blob/master/x-pack/legacy/plugins/maps/public/connected_components/map/mb/view.js
//
// manual list of exception modules
const manualExceptionModules = [
'mapbox-gl'
];

// consider the top modules as exceptions as the entry points
// to look for other exceptions dependent on that one
const manualExceptionEntries = [
...manualExceptionModules.map(module => `${baseDir}/node_modules/${module}`)
];

// dependencies for declared exception modules
const manualExceptionModulesDependencies = await getDependencies(baseDir, [
...manualExceptionEntries
]);

// final list of manual exceptions to add
const manualExceptions = [
...manualExceptionModules,
...manualExceptionModulesDependencies
];

// Consider this as our whiteList for the modules we can't delete
const whiteListedModules = [
...serverDependencies,
...kbnWebpackLoaders
...kbnWebpackLoaders,
...manualExceptions
];

// Resolve the client vendors dll manifest path
Expand Down
2 changes: 0 additions & 2 deletions src/legacy/server/csp/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ test('default CSP rules', () => {
expect(DEFAULT_CSP_RULES).toMatchInlineSnapshot(`
Array [
"script-src 'unsafe-eval' 'self'",
"worker-src blob:",
"child-src blob:",
"style-src 'unsafe-inline' 'self'",
]
`);
Expand Down
2 changes: 0 additions & 2 deletions src/legacy/server/csp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

export const DEFAULT_CSP_RULES = Object.freeze([
`script-src 'unsafe-eval' 'self'`,
'worker-src blob:',
'child-src blob:',
`style-src 'unsafe-inline' 'self'`,
]);

Expand Down
2 changes: 0 additions & 2 deletions test/api_integration/apis/general/csp.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ export default function ({ getService }) {
const entries = Array.from(parsed.entries());
expect(entries).to.eql([
[ 'script-src', [ '\'unsafe-eval\'', '\'self\'' ] ],
[ 'worker-src', [ 'blob:' ] ],
[ 'child-src', [ 'blob:' ] ],
[ 'style-src', [ '\'unsafe-inline\'', '\'self\'' ] ]
]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,21 @@ import {
addSpritesheetToMap,
} from './utils';
import { getGlyphUrl, isRetina } from '../../../meta';
import { DECIMAL_DEGREES_PRECISION, ZOOM_PRECISION } from '../../../../common/constants';
import mapboxgl from 'mapbox-gl';
import {
DECIMAL_DEGREES_PRECISION,
ZOOM_PRECISION,
} from '../../../../common/constants';
import mapboxgl from 'mapbox-gl/dist/mapbox-gl-csp';
import mbWorkerUrl from '!!file-loader!mapbox-gl/dist/mapbox-gl-csp-worker';
import chrome from 'ui/chrome';
import { spritesheet } from '@elastic/maki';
import sprites1 from '@elastic/maki/dist/sprite@1.png';
import sprites2 from '@elastic/maki/dist/sprite@2.png';
import { DrawControl } from './draw_control';
import { TooltipControl } from './tooltip_control';

mapboxgl.workerUrl = mbWorkerUrl;

export class MBMapContainer extends React.Component {
state = {
prevLayerList: undefined,
Expand Down