Skip to content

export default problems #6258

@kimjoar

Description

@kimjoar

I've found some potential bugs that works with Babel 5, but correctly breaks with Babel 6.

module.exports and exports default are different in some important ways, e.g. that this isn't allowed:

// foo.js
export default { baz: 42, bar: false }

// bar.js
import { baz } from './foo'

Instead it should be:

export const baz = 42;
export const bar = false;

I see we export an object several places:

$ find ./src -name "*.js" | xargs grep -l "export default {"
./src/cli/plugin/plugin_installer.js
./src/fixtures/field_mapping.js
./src/fixtures/filter_skeleton.js
./src/fixtures/mapping_with_dupes.js
./src/fixtures/mock_ui_state.js
./src/fixtures/search_response.js
./src/plugins/kibana/public/discover/components/field_chooser/lib/field_calculator.js
./src/plugins/kibana/public/settings/saved_object_registry.js
./src/ui/public/modules.js
./src/ui/public/utils/date_range.js
./src/ui/public/utils/dateMath.js
./src/ui/public/utils/key_map.js
./src/ui/public/utils/sequencer.js
./src/ui/public/utils/supports.js

We should probably go through these exports and fix them. We might need smarter search too, in order to catch things like:

// foo.js
const obj = { baz: 42, bar: false };
export default obj;

// bar.js
import { baz } from './foo'

Might be possible to use jscodeshift, jsfmt or something else to search for it (or just upgrade and see where it breaks 🙈)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Team:CorePlatform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t//choredev

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions