Browse Source

Feature/universal entry (#195)

* Remove file extension

* Update docs

* Update the deafult 'entry' test
v6-dev
Constantine Genchevsky 8 years ago
committed by Eli Perelman
parent
commit
9d7029f0fb
  1. 5
      docs/api/README.md
  2. 7
      docs/creating-presets.md
  3. 7
      docs/customization/advanced.md
  4. 7
      docs/customization/simple.md
  5. 4
      docs/presets/neutrino-preset-react/README.md
  6. 5
      docs/presets/neutrino-preset-web/README.md
  7. 4
      packages/neutrino/src/api.js
  8. 2
      packages/neutrino/test/api_test.js

5
docs/api/README.md

@ -137,12 +137,11 @@ Neutrino({
### `options.entry`
Set the main entry point for the application. If the option is not set, Neutrino defaults it to `index.js`.
If a relative path is specified, it will be resolved relative to `options.source`; absolute paths will be used as-is.
Set the main entry point for the application. If the option is not set, Neutrino defaults it to `index.*` - the extension is resolved by Webpack. The main file by default is not required to be in JavaScript format. If a relative path is specified, it will be resolved relative to `options.source`; absolute paths will be used as-is.
```js
Neutrino({
// if not specified, defaults to options.source + index.js
// if not specified, defaults to options.source + index
// relative, resolves to options.source + ./entry.js
entry: './entry.js',

7
docs/creating-presets.md

@ -231,12 +231,13 @@ module.exports = neutrino => {
### `options.entry`
Set the main entry point for the application. If the option is not set, Neutrino defaults it to `index.js`.
If a relative path is specified, it will be resolved relative to `options.source`; absolute paths will be used as-is.
Set the main entry point for the application. If the option is not set, Neutrino defaults it to `index.*` - the extension is resolved by Webpack. If a relative path is specified, it will be resolved relative to `options.source`; absolute paths will be used as-is.
The main file by default is not required to be in JavaScript format. It also potentially may be JSX, TypeScript or any other preprocessor language. These extensions should be specified in a preset in `neutrino.config.resolve.extensions`.
```js
module.exports = neutrino => {
// if not specified, defaults to options.source + index.js
// if not specified, defaults to options.source + index
neutrino.options.entry;
// relative, resolves to options.source + ./entry.js

7
docs/customization/advanced.md

@ -142,12 +142,13 @@ module.exports = neutrino => {
### `options.entry`
Set the main entry point for the application. If the option is not set, Neutrino defaults it to `index.js`.
If a relative path is specified, it will be resolved relative to `options.source`; absolute paths will be used as-is.
Set the main entry point for the application. If the option is not set, Neutrino defaults it to `index.*` - the extension is resolved by Webpack. If a relative path is specified, it will be resolved relative to `options.source`; absolute paths will be used as-is.
The main file by default is not required to be in JavaScript format. It also potentially may be JSX, TypeScript or any other preprocessor language. These extensions should be specified in a preset in `neutrino.config.resolve.extensions`.
```js
module.exports = neutrino => {
// if not specified, defaults to options.source + index.js
// if not specified, defaults to options.source + index
neutrino.options.entry;
// relative, resolves to options.source + ./entry.js

7
docs/customization/simple.md

@ -122,14 +122,15 @@ If a relative path is specified, it will be resolved relative to `options.root`;
### `options.entry`
Set the main entry point for the application. If the option is not set, Neutrino defaults it to `index.js`.
If a relative path is specified, it will be resolved relative to `options.source`; absolute paths will be used as-is.
Set the main entry point for the application. If the option is not set, Neutrino defaults it to `index.*` - the extension is resolved by Webpack. If a relative path is specified, it will be resolved relative to `options.source`; absolute paths will be used as-is.
The main file by default is not required to be in JavaScript format. It also potentially may be JSX, TypeScript or any other preprocessor language. These extensions should be specified in a preset in `neutrino.config.resolve.extensions`.
```js
{
"neutrino": {
"options": {
// if not specified, defaults to options.source + index.js
// if not specified, defaults to options.source + index
// relative, resolves to options.source + ./entry.js
"entry": "./entry.js",

4
docs/presets/neutrino-preset-react/README.md

@ -246,8 +246,8 @@ First, install `react-hot-loader` as a dependency, this **must** be React Hot Lo
---
- From your `index` entry point (defaults to `src/index.js` from `neutrino.options.entry`), import an `AppContainer`
from `react-hot-loader`.
- From your `index` entry point (defaults to `src/index.*` from `neutrino.options.entry`), import an `AppContainer`
from `react-hot-loader`. The main file may be named `index.js` or `index.jsx`. The extension is resolved by Webpack.
- Wrap your top-level React component in the `AppContainer`.
- Perform the application render in a reusable function for initial load and subsequent reloads.
- Add the `hot` acceptance to call this function.

5
docs/presets/neutrino-preset-web/README.md

@ -166,10 +166,7 @@ To override the build configuration, start with the documentation on [customizat
`neutrino-preset-web` creates some conventions to make overriding the configuration easier once you are ready to make
changes.
By default the Web preset creates a single **main** `index` entry point to your application, and this maps to the
`index.js` file in the `src` directory. This value is provided by `neutrino.options.entry`.
This means that the Web preset is optimized toward the use case of single-page applications over multi-page
applications.
By default the Web preset creates a single **main** `index` entry point to your application, and this maps to the `index.*` file in the `src` directory. The extension is resolved by Webpack. This value is provided by `neutrino.options.entry`. This means that the Web preset is optimized toward the use case of single-page applications over multi-page applications.
### Rules

4
packages/neutrino/src/api.js

@ -16,7 +16,7 @@ const getOptions = (options = {}) => {
let output = defaultTo('build', options.output);
let tests = defaultTo('test', options.tests);
let node_modules = defaultTo('node_modules', options.node_modules); // eslint-disable-line camelcase
let entry = defaultTo('index.js', options.entry);
let entry = defaultTo('index', options.entry);
Object.defineProperties(options, {
root: {
@ -64,7 +64,7 @@ const getOptions = (options = {}) => {
return normalizePath(this.source, entry);
},
set(value) {
entry = defaultTo('index.js', value);
entry = defaultTo('index', value);
}
}
});

2
packages/neutrino/test/api_test.js

@ -80,7 +80,7 @@ test('options.node_modules', t => {
test('options.entry', t => {
const api = Neutrino();
t.is(api.options.entry, join(process.cwd(), 'src/index.js'));
t.is(api.options.entry, join(process.cwd(), 'src/index'));
api.options.entry = './alpha.js';
t.is(api.options.entry, join(process.cwd(), 'src/alpha.js'));
api.options.source = 'beta';

Loading…
Cancel
Save