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

Use es6 exports, replace module.exports #12084

Merged
merged 24 commits into from
Jun 6, 2017

Conversation

w33ble
Copy link
Contributor

@w33ble w33ble commented May 30, 2017

There's a lot of places in Kibana where module.exports is still used, despite our having moved to es6 modules a while ago. This causes problems when static analyzers try to resolve those exports.

This PR is the result of using the exports transform from 5to6-codemod, and a little manual cleanup.

Since this change basically equates to using export default, there's a conflict with our kibana-custom/no-default-export eslint rule. I wanted to keep the scope of this PR down and avoid larger refactoring, so I added exceptions to the code. We can always clean them up in another PR.

@w33ble w33ble added Team:Operations Team label for Operations Team chore dev WIP Work in progress labels May 30, 2017
@w33ble w33ble force-pushed the dev/replace-module-exports branch 2 times, most recently from af39b18 to 0b013c0 Compare May 31, 2017 01:44
@spalger spalger self-requested a review May 31, 2017 18:04
@w33ble w33ble force-pushed the dev/replace-module-exports branch from 37f0990 to 88f9808 Compare May 31, 2017 18:52
@w33ble w33ble requested review from tylersmalley and rhoboat May 31, 2017 20:12
@w33ble w33ble added review and removed WIP Work in progress labels May 31, 2017
@w33ble w33ble force-pushed the dev/replace-module-exports branch from 0612b12 to 69c84ce Compare May 31, 2017 21:57
Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, CI passes and changes look good after a good skim. 🛳

@tylersmalley
Copy link
Contributor

I am getting an error building when not in dev mode

  log   [00:22:17.871] [info][optimize] Optimizing and caching bundles for kibana, stateSessionStorageRedirect, timelion, sense-tests and status_page. This may take a few minutes
  log   [00:22:59.717] [fatal] Error: Optimizations failure.

    ERROR in kibana.bundle.js from UglifyJs
    SyntaxError: Name expected [kibana.bundle.js:89156,5]

    ERROR in timelion.bundle.js from UglifyJs
    SyntaxError: Name expected [timelion.bundle.js:88897,5]

    at Object.exports.create (/Users/tyler/elastic/kibana/node_modules/boom/lib/index.js:21:17)
    at FsOptimizer.failedStatsToError (/Users/tyler/elastic/kibana/src/optimize/base_optimizer.js:224:17)
    at /Users/tyler/elastic/kibana/src/optimize/fs_optimizer.js:17:26
    at Compiler.<anonymous> (/Users/tyler/elastic/kibana/node_modules/webpack/lib/Compiler.js:181:13)
    at /Users/tyler/elastic/kibana/node_modules/webpack/lib/Compiler.js:403:12
    at Compiler.next (/Users/tyler/elastic/kibana/node_modules/tapable/lib/Tapable.js:67:11)
    at Compiler.<anonymous> (/Users/tyler/elastic/kibana/node_modules/webpack/lib/CachePlugin.js:40:4)
    at Compiler.applyPluginsAsync (/Users/tyler/elastic/kibana/node_modules/tapable/lib/Tapable.js:71:13)
    at Compiler.<anonymous> (/Users/tyler/elastic/kibana/node_modules/webpack/lib/Compiler.js:400:9)
    at Compilation.<anonymous> (/Users/tyler/elastic/kibana/node_modules/webpack/lib/Compilation.js:577:13)
    at Compilation.applyPluginsAsync (/Users/tyler/elastic/kibana/node_modules/tapable/lib/Tapable.js:60:69)
    at Compilation.<anonymous> (/Users/tyler/elastic/kibana/node_modules/webpack/lib/Compilation.js:572:10)
    at Compilation.next (/Users/tyler/elastic/kibana/node_modules/tapable/lib/Tapable.js:67:11)
    at Compilation.<anonymous> (/Users/tyler/elastic/kibana/node_modules/webpack/lib/optimize/UglifyJsPlugin.js:140:4)
    at Compilation.applyPluginsAsync (/Users/tyler/elastic/kibana/node_modules/tapable/lib/Tapable.js:71:13)
    at Compilation.<anonymous> (/Users/tyler/elastic/kibana/node_modules/webpack/lib/Compilation.js:567:9)
FATAL { Error: Optimizations failure.

    ERROR in kibana.bundle.js from UglifyJs
    SyntaxError: Name expected [kibana.bundle.js:89156,5]

    ERROR in timelion.bundle.js from UglifyJs
    SyntaxError: Name expected [timelion.bundle.js:88897,5]

    at Object.exports.create (/Users/tyler/elastic/kibana/node_modules/boom/lib/index.js:21:17)
    at FsOptimizer.failedStatsToError (/Users/tyler/elastic/kibana/src/optimize/base_optimizer.js:224:17)
    at /Users/tyler/elastic/kibana/src/optimize/fs_optimizer.js:17:26
    at Compiler.<anonymous> (/Users/tyler/elastic/kibana/node_modules/webpack/lib/Compiler.js:181:13)
    at /Users/tyler/elastic/kibana/node_modules/webpack/lib/Compiler.js:403:12
    at Compiler.next (/Users/tyler/elastic/kibana/node_modules/tapable/lib/Tapable.js:67:11)
    at Compiler.<anonymous> (/Users/tyler/elastic/kibana/node_modules/webpack/lib/CachePlugin.js:40:4)
    at Compiler.applyPluginsAsync (/Users/tyler/elastic/kibana/node_modules/tapable/lib/Tapable.js:71:13)
    at Compiler.<anonymous> (/Users/tyler/elastic/kibana/node_modules/webpack/lib/Compiler.js:400:9)
    at Compilation.<anonymous> (/Users/tyler/elastic/kibana/node_modules/webpack/lib/Compilation.js:577:13)
    at Compilation.applyPluginsAsync (/Users/tyler/elastic/kibana/node_modules/tapable/lib/Tapable.js:60:69)
    at Compilation.<anonymous> (/Users/tyler/elastic/kibana/node_modules/webpack/lib/Compilation.js:572:10)
    at Compilation.next (/Users/tyler/elastic/kibana/node_modules/tapable/lib/Tapable.js:67:11)
    at Compilation.<anonymous> (/Users/tyler/elastic/kibana/node_modules/webpack/lib/optimize/UglifyJsPlugin.js:140:4)
    at Compilation.applyPluginsAsync (/Users/tyler/elastic/kibana/node_modules/tapable/lib/Tapable.js:71:13)
    at Compilation.<anonymous> (/Users/tyler/elastic/kibana/node_modules/webpack/lib/Compilation.js:567:9)
  cause:
   { Error: Optimizations failure.

       ERROR in kibana.bundle.js from UglifyJs
       SyntaxError: Name expected [kibana.bundle.js:89156,5]

       ERROR in timelion.bundle.js from UglifyJs
       SyntaxError: Name expected [timelion.bundle.js:88897,5]

       at Object.exports.create (/Users/tyler/elastic/kibana/node_modules/boom/lib/index.js:21:17)
       at FsOptimizer.failedStatsToError (/Users/tyler/elastic/kibana/src/optimize/base_optimizer.js:224:17)
       at /Users/tyler/elastic/kibana/src/optimize/fs_optimizer.js:17:26
       at Compiler.<anonymous> (/Users/tyler/elastic/kibana/node_modules/webpack/lib/Compiler.js:181:13)
       at /Users/tyler/elastic/kibana/node_modules/webpack/lib/Compiler.js:403:12
       at Compiler.next (/Users/tyler/elastic/kibana/node_modules/tapable/lib/Tapable.js:67:11)
       at Compiler.<anonymous> (/Users/tyler/elastic/kibana/node_modules/webpack/lib/CachePlugin.js:40:4)
       at Compiler.applyPluginsAsync (/Users/tyler/elastic/kibana/node_modules/tapable/lib/Tapable.js:71:13)
       at Compiler.<anonymous> (/Users/tyler/elastic/kibana/node_modules/webpack/lib/Compiler.js:400:9)
       at Compilation.<anonymous> (/Users/tyler/elastic/kibana/node_modules/webpack/lib/Compilation.js:577:13)
       at Compilation.applyPluginsAsync (/Users/tyler/elastic/kibana/node_modules/tapable/lib/Tapable.js:60:69)
       at Compilation.<anonymous> (/Users/tyler/elastic/kibana/node_modules/webpack/lib/Compilation.js:572:10)
       at Compilation.next (/Users/tyler/elastic/kibana/node_modules/tapable/lib/Tapable.js:67:11)
       at Compilation.<anonymous> (/Users/tyler/elastic/kibana/node_modules/webpack/lib/optimize/UglifyJsPlugin.js:140:4)
       at Compilation.applyPluginsAsync (/Users/tyler/elastic/kibana/node_modules/tapable/lib/Tapable.js:71:13)
       at Compilation.<anonymous> (/Users/tyler/elastic/kibana/node_modules/webpack/lib/Compilation.js:567:9)
     data: { errors: [Object], warnings: [], publicPath: '/bundles/' },
     isBoom: true,
     isServer: true,
     output: { statusCode: 500, payload: [Object], headers: {} },
     reformat: [Function] },
  isOperational: true,
  data:
   { errors:
      [ 'kibana.bundle.js from UglifyJs\nSyntaxError: Name expected [kibana.bundle.js:89156,5]',
        'timelion.bundle.js from UglifyJs\nSyntaxError: Name expected [timelion.bundle.js:88897,5]' ],
     warnings: [],
     publicPath: '/bundles/' },
  isBoom: true,
  isServer: true,
  output:
   { statusCode: 500,
     payload:
      { statusCode: 500,
        error: 'Internal Server Error',
        message: 'An internal server error occurred' },
     headers: {} },
  reformat: [Function] }

@w33ble w33ble force-pushed the dev/replace-module-exports branch 2 times, most recently from ae4bffd to 8be360e Compare June 2, 2017 19:15
@w33ble w33ble force-pushed the dev/replace-module-exports branch from d73580f to f131c59 Compare June 5, 2017 22:10
@@ -1,5 +1,5 @@
import expect from 'expect.js';
import createProxy from '../create_proxy';
import { createProxy } from '../create_proxy';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be importing createPath here and update the references for the tests to pass.

@w33ble w33ble force-pushed the dev/replace-module-exports branch from f131c59 to 729a456 Compare June 5, 2017 22:49
Copy link
Contributor

@tylersmalley tylersmalley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - tested build against x-pack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants