From 0675f85d323612df1815f2730048f1772cbf854a Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 30 Mar 2016 16:38:34 +1300 Subject: [PATCH] Use /index suffix for JS import statements Otherwise browserify or gulp-sourcemaps doesn't include these in the *.map file, which makes debugging impossible --- admin/javascript/src/boot/index.js | 2 +- .../src/components/form-action/index.js | 2 +- .../src/components/form-builder/index.js | 10 ++-- .../form-builder/tests/form-builder-test.js | 2 +- admin/javascript/src/components/form/index.js | 4 +- .../src/components/grid-field/cell.js | 2 +- .../src/components/grid-field/header-cell.js | 2 +- .../src/components/grid-field/header.js | 2 +- .../src/components/grid-field/index.js | 2 +- .../src/components/grid-field/row.js | 2 +- .../src/components/grid-field/table.js | 2 +- .../src/components/hidden-field/index.js | 2 +- .../north-header-breadcrumbs/index.js | 2 +- .../src/components/north-header/index.js | 4 +- .../src/components/text-field/index.js | 2 +- .../src/sections/campaign-admin/controller.js | 6 +- gulpfile.js | 60 +++++++++---------- 17 files changed, 54 insertions(+), 54 deletions(-) diff --git a/admin/javascript/src/boot/index.js b/admin/javascript/src/boot/index.js index 3a450d278..9e258836e 100644 --- a/admin/javascript/src/boot/index.js +++ b/admin/javascript/src/boot/index.js @@ -10,7 +10,7 @@ import SchemaReducer from 'state/schema/reducer'; import RecordsReducer from 'state/records/reducer'; // Sections -import CampaignAdmin from 'sections/campaign-admin'; +import CampaignAdmin from 'sections/campaign-admin/index'; function appBoot() { reducerRegister.add('config', ConfigReducer); diff --git a/admin/javascript/src/components/form-action/index.js b/admin/javascript/src/components/form-action/index.js index f59d184eb..c0ade7191 100644 --- a/admin/javascript/src/components/form-action/index.js +++ b/admin/javascript/src/components/form-action/index.js @@ -1,5 +1,5 @@ import React from 'react'; -import SilverStripeComponent from 'silverstripe-component.js'; +import SilverStripeComponent from 'silverstripe-component'; class FormActionComponent extends SilverStripeComponent { constructor(props) { diff --git a/admin/javascript/src/components/form-builder/index.js b/admin/javascript/src/components/form-builder/index.js index 9ada30800..a9790b866 100644 --- a/admin/javascript/src/components/form-builder/index.js +++ b/admin/javascript/src/components/form-builder/index.js @@ -3,11 +3,11 @@ import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import $ from 'jQuery'; import * as schemaActions from 'state/schema/actions'; -import SilverStripeComponent from 'silverstripe-component.js'; -import FormComponent from 'components/form'; -import TextField from 'components/text-field'; -import HiddenField from 'components/hidden-field'; -import GridField from 'components/grid-field'; +import SilverStripeComponent from 'silverstripe-component'; +import FormComponent from 'components/form/index'; +import TextField from 'components/text-field/index'; +import HiddenField from 'components/hidden-field/index'; +import GridField from 'components/grid-field/index'; import fetch from 'isomorphic-fetch'; import es6promise from 'es6-promise'; diff --git a/admin/javascript/src/components/form-builder/tests/form-builder-test.js b/admin/javascript/src/components/form-builder/tests/form-builder-test.js index 760f44e89..977b7d7c5 100644 --- a/admin/javascript/src/components/form-builder/tests/form-builder-test.js +++ b/admin/javascript/src/components/form-builder/tests/form-builder-test.js @@ -1,4 +1,4 @@ -jest.unmock('silverstripe-component.js'); +jest.unmock('silverstripe-component'); jest.unmock('../'); import { FormBuilderComponent } from '../'; diff --git a/admin/javascript/src/components/form/index.js b/admin/javascript/src/components/form/index.js index 0f45bb95e..47f3d4893 100644 --- a/admin/javascript/src/components/form/index.js +++ b/admin/javascript/src/components/form/index.js @@ -1,6 +1,6 @@ import React from 'react'; -import SilverStripeComponent from 'silverstripe-component.js'; -import FormActionComponent from 'components/form-action'; +import SilverStripeComponent from 'silverstripe-component'; +import FormActionComponent from 'components/form-action/index'; class FormComponent extends SilverStripeComponent { diff --git a/admin/javascript/src/components/grid-field/cell.js b/admin/javascript/src/components/grid-field/cell.js index 5e55738dd..368941739 100644 --- a/admin/javascript/src/components/grid-field/cell.js +++ b/admin/javascript/src/components/grid-field/cell.js @@ -1,5 +1,5 @@ import React from 'react'; -import SilverStripeComponent from 'silverstripe-component.js'; +import SilverStripeComponent from 'silverstripe-component'; class GridFieldCellComponent extends SilverStripeComponent { diff --git a/admin/javascript/src/components/grid-field/header-cell.js b/admin/javascript/src/components/grid-field/header-cell.js index e6c7aee7f..d23c294c8 100644 --- a/admin/javascript/src/components/grid-field/header-cell.js +++ b/admin/javascript/src/components/grid-field/header-cell.js @@ -1,5 +1,5 @@ import React from 'react'; -import SilverStripeComponent from 'silverstripe-component.js'; +import SilverStripeComponent from 'silverstripe-component'; class GridFieldHeaderCellComponent extends SilverStripeComponent { diff --git a/admin/javascript/src/components/grid-field/header.js b/admin/javascript/src/components/grid-field/header.js index 06c6e9e15..dcf26a8fb 100644 --- a/admin/javascript/src/components/grid-field/header.js +++ b/admin/javascript/src/components/grid-field/header.js @@ -1,5 +1,5 @@ import React from 'react'; -import SilverStripeComponent from 'silverstripe-component.js'; +import SilverStripeComponent from 'silverstripe-component'; import GridFieldRowComponent from './row'; class GridFieldHeaderComponent extends SilverStripeComponent { diff --git a/admin/javascript/src/components/grid-field/index.js b/admin/javascript/src/components/grid-field/index.js index 1b23c4c8c..76a5aaa90 100644 --- a/admin/javascript/src/components/grid-field/index.js +++ b/admin/javascript/src/components/grid-field/index.js @@ -1,7 +1,7 @@ import React from 'react'; import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; -import SilverStripeComponent from 'silverstripe-component.js'; +import SilverStripeComponent from 'silverstripe-component'; import GridFieldTable from './table'; import GridFieldHeader from './header'; import GridFieldHeaderCell from './header-cell'; diff --git a/admin/javascript/src/components/grid-field/row.js b/admin/javascript/src/components/grid-field/row.js index 74479f50b..a2c945553 100644 --- a/admin/javascript/src/components/grid-field/row.js +++ b/admin/javascript/src/components/grid-field/row.js @@ -1,5 +1,5 @@ import React from 'react'; -import SilverStripeComponent from 'silverstripe-component.js'; +import SilverStripeComponent from 'silverstripe-component'; class GridFieldRowComponent extends SilverStripeComponent { diff --git a/admin/javascript/src/components/grid-field/table.js b/admin/javascript/src/components/grid-field/table.js index 76d205ca3..479acdeaa 100644 --- a/admin/javascript/src/components/grid-field/table.js +++ b/admin/javascript/src/components/grid-field/table.js @@ -1,5 +1,5 @@ import React from 'react'; -import SilverStripeComponent from 'silverstripe-component.js'; +import SilverStripeComponent from 'silverstripe-component'; class GridFieldTableComponent extends SilverStripeComponent { diff --git a/admin/javascript/src/components/hidden-field/index.js b/admin/javascript/src/components/hidden-field/index.js index 309a77103..0b36ba916 100644 --- a/admin/javascript/src/components/hidden-field/index.js +++ b/admin/javascript/src/components/hidden-field/index.js @@ -1,5 +1,5 @@ import React from 'react'; -import SilverStripeComponent from 'silverstripe-component.js'; +import SilverStripeComponent from 'silverstripe-component'; class HiddenFieldComponent extends SilverStripeComponent { diff --git a/admin/javascript/src/components/north-header-breadcrumbs/index.js b/admin/javascript/src/components/north-header-breadcrumbs/index.js index 5e2f1be31..1bacb6c6e 100644 --- a/admin/javascript/src/components/north-header-breadcrumbs/index.js +++ b/admin/javascript/src/components/north-header-breadcrumbs/index.js @@ -1,5 +1,5 @@ import React from 'react'; -import SilverStripeComponent from 'silverstripe-component.js'; +import SilverStripeComponent from 'silverstripe-component'; class NorthHeaderBreadcrumbsComponent extends SilverStripeComponent { diff --git a/admin/javascript/src/components/north-header/index.js b/admin/javascript/src/components/north-header/index.js index d4ea019ef..45473fda0 100644 --- a/admin/javascript/src/components/north-header/index.js +++ b/admin/javascript/src/components/north-header/index.js @@ -1,6 +1,6 @@ import React from 'react'; -import NorthHeaderBreadcrumbsComponent from '../north-header-breadcrumbs'; -import SilverStripeComponent from 'silverstripe-component.js'; +import NorthHeaderBreadcrumbsComponent from '../north-header-breadcrumbs/index'; +import SilverStripeComponent from 'silverstripe-component'; class NorthHeaderComponent extends SilverStripeComponent { diff --git a/admin/javascript/src/components/text-field/index.js b/admin/javascript/src/components/text-field/index.js index 9ef3ffccb..166c8925f 100644 --- a/admin/javascript/src/components/text-field/index.js +++ b/admin/javascript/src/components/text-field/index.js @@ -1,5 +1,5 @@ import React from 'react'; -import SilverStripeComponent from 'silverstripe-component.js'; +import SilverStripeComponent from 'silverstripe-component'; class TextFieldComponent extends SilverStripeComponent { diff --git a/admin/javascript/src/sections/campaign-admin/controller.js b/admin/javascript/src/sections/campaign-admin/controller.js index abcaf0452..ea88fe6ca 100644 --- a/admin/javascript/src/sections/campaign-admin/controller.js +++ b/admin/javascript/src/sections/campaign-admin/controller.js @@ -1,10 +1,10 @@ import React from 'react'; import { connect } from 'react-redux'; import SilverStripeComponent from 'silverstripe-component'; -import FormAction from 'components/form-action'; +import FormAction from 'components/form-action/index'; import i18n from 'i18n'; -import NorthHeader from 'components/north-header'; -import FormBuilder from 'components/form-builder'; +import NorthHeader from 'components/north-header/index'; +import FormBuilder from 'components/form-builder/index'; class CampaignAdminContainer extends SilverStripeComponent { diff --git a/gulpfile.js b/gulpfile.js index 901f3bb72..64fb3c8b1 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -192,32 +192,32 @@ gulp.task('bundle-lib', function bundleLib() { .on('update', bundleLib) .on('log', function (msg) { gulpUtil.log('Finished', 'bundled ' + bundleFileName + ' ' + msg) }) .transform('babelify', babelifyOptions) - .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/form', { expose: 'components/form' }) - .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/form-action', { expose: 'components/form-action' }) - .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/form-builder', { expose: 'components/form-builder' }) - .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/grid-field', { expose: 'components/grid-field' }) - .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/grid-field/cell', { expose: 'components/grid-field/cell' }) - .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/grid-field/header', { expose: 'components/grid-field/header' }) - .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/grid-field/header-cell', { expose: 'components/grid-field/header-cell' }) - .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/grid-field/row', { expose: 'components/grid-field/row' }) - .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/grid-field/table', { expose: 'components/grid-field/table' }) - .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/hidden-field', { expose: 'components/hidden-field' }) - .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/text-field', { expose: 'components/text-field' }) - .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/north-header', { expose: 'components/north-header' }) - .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/north-header-breadcrumbs', { expose: 'components/north-header-breadcrumbs' }) - .require('deep-freeze', { expose: 'deep-freeze' }) - .require(PATHS.FRAMEWORK_JAVASCRIPT_SRC + '/i18n.js', { expose: 'i18n' }) - .require(PATHS.FRAMEWORK_JAVASCRIPT_SRC + '/jQuery.js', { expose: 'jQuery' }) - .require('react', { expose: 'react' }) - .require('react-addons-css-transition-group', { expose: 'react-addons-css-transition-group' }) - .require('react-addons-test-utils', { expose: 'react-addons-test-utils' }) - .require('react-dom', { expose: 'react-dom' }) - .require('react-redux', { expose: 'react-redux' }) - .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/reducer-register.js', { expose: 'reducer-register' }) - .require('redux', { expose: 'redux' }) - .require('redux-thunk', { expose: 'redux-thunk' }) - .require(PATHS.FRAMEWORK_JAVASCRIPT_SRC + '/router.js', { expose: 'router' }) - .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/silverstripe-component.js', { expose: 'silverstripe-component' }) + .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/form/index', { expose: 'components/form/index' }) + .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/form-action/index', { expose: 'components/form-action' }) + .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/form-builder/index', { expose: 'components/form-builder/index' }) + .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/grid-field/index', { expose: 'components/grid-field/index' }) + .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/grid-field/cell', { expose: 'components/grid-field/cell/index' }) + .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/grid-field/header', { expose: 'components/grid-field/header' }) + .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/grid-field/header-cell', { expose: 'components/grid-field/header-cell' }) + .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/grid-field/row', { expose: 'components/grid-field/row' }) + .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/grid-field/table', { expose: 'components/grid-field/table' }) + .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/hidden-field/index', { expose: 'components/hidden-field/index' }) + .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/text-field/index', { expose: 'components/text-field/index' }) + .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/north-header/index', { expose: 'components/north-header/index' }) + .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/components/north-header-breadcrumbs/index', { expose: 'components/north-header-breadcrumbs/index' }) + .require('deep-freeze', { expose: 'deep-freeze' }) + .require(PATHS.FRAMEWORK_JAVASCRIPT_SRC + '/i18n.js', { expose: 'i18n' }) + .require(PATHS.FRAMEWORK_JAVASCRIPT_SRC + '/jQuery.js', { expose: 'jQuery' }) + .require('react', { expose: 'react' }) + .require('react-addons-css-transition-group', { expose: 'react-addons-css-transition-group' }) + .require('react-addons-test-utils', { expose: 'react-addons-test-utils' }) + .require('react-dom', { expose: 'react-dom' }) + .require('react-redux', { expose: 'react-redux' }) + .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/reducer-register.js', { expose: 'reducer-register' }) + .require('redux', { expose: 'redux' }) + .require('redux-thunk', { expose: 'redux-thunk' }) + .require(PATHS.FRAMEWORK_JAVASCRIPT_SRC + '/router.js', { expose: 'router' }) + .require(PATHS.ADMIN_JAVASCRIPT_SRC + '/silverstripe-component', { expose: 'silverstripe-component' }) .bundle() .on('update', bundleLib) .on('error', notify.onError({ message: bundleFileName + ': <%= error.message %>' })) @@ -258,11 +258,11 @@ gulp.task('bundle-framework', function bundleBoot() { .on('update', bundleBoot) .on('log', function (msg) { gulpUtil.log('Finished', 'bundled ' + bundleFileName + ' ' + msg) }) .transform('babelify', babelifyOptions) - .external('components/action-button') - .external('components/north-header') - .external('components/form-builder') + .external('components/action-button/index') + .external('components/north-header/index') + .external('components/form-builder/index') .external('deep-freeze') - .external('components/grid-field') + .external('components/grid-field/index') .external('i18n') .external('jQuery') .external('page.js')