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

v8.0.0 #101

Merged
merged 18 commits into from
Dec 31, 2019
Merged
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
5 changes: 1 addition & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"root": true,
"plugins": ["homer0"],
"extends": ["plugin:homer0/node"],
"rules": {
"complexity": "off"
}
"extends": ["plugin:homer0/node"]
}
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.10
10.13
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- "8.11"
- "10.15"
- "10.18"
- "12.14"
after_success:
- 'cat ./coverage/lcov.info | ./node_modules/.bin/coveralls'
2 changes: 1 addition & 1 deletion README-esdoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ This is aimed to those who use bundlers everyday to build web sites, libraries a
|--------------|-------------------------------------------------------------------------------|
| Package | projext |
| Description | Bundle your Javascript projects without having to learn how to use a bundler. |
| Node Version | >= v8.0.0 |
| Node Version | >= v10.13.0 |

## Usage

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ This is aimed to those who use bundlers everyday to build web sites, libraries a
|--------------|-------------------------------------------------------------------------------|
| Package | projext |
| Description | Bundle your Javascript projects without having to learn how to use a bundler. |
| Node Version | >= v8.0.0 |
| Node Version | >= v10.13.0 |

## Usage

Expand Down
14 changes: 13 additions & 1 deletion documents/projectConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ Using this flags, you can tell projext to always watch your files when building
> objectRestSpread: false,
> },
> nodeVersion: 'current',
> env: {},
> overwrites: {},
> }
> ```
Expand All @@ -333,6 +334,10 @@ If you need other plugins, they can be included on the `overwrites` option.

When building the Babel configuration, projext uses the [`@babel/preset-env`](https://yarnpkg.com/en/package/@babel/preset-env) to just include the necessary stuff. This setting tells the preset the version of Node it should _"complete"_.

**`babel.env`**

Custom settings that projext will use as base when generating the ones for the [`@babel/preset-env`](https://yarnpkg.com/en/package/@babel/preset-env).

**`babel.overwrites`**

If you know how to use Babel and need stuff that is not covered by projext, you can use this setting to overwrite/add any value you may need.
Expand Down Expand Up @@ -652,6 +657,7 @@ Using this flags, you can tell projext to always watch your files when building
> browserVersions: 2,
> mobileSupport: true,
> polyfill: true,
> env: {},
> overwrites: {},
> }
> ```
Expand Down Expand Up @@ -681,7 +687,13 @@ If `true`, the configuration will add to the list of major browsers `iOS` and `A

**`babel.polyfill`**

Whether or not the configuration should include the [`babel-polyfill`](https://yarnpkg.com/en/package/babel-polyfill) package.
Whether or not the configuration for the [`@babel/preset-env`](https://yarnpkg.com/en/package/@babel/preset-env) should include the settings for [`useBuiltIns` and `corejs`](https://babeljs.io/docs/en/babel-preset-env#usebuiltins).

Something that should be noted is that if `babel.polyfill` is set to `true`, projext will set `useBuiltIns` to `usage`; if you want to change it to `entry`, you have to change it using `babel.env` (explained below) and manually import [`core-js/stable`](https://yarnpkg.com/en/package/core-js) and [`regenerator-runtime/runtime`](https://yarnpkg.com/en/package/regenerator-runtime). If you do it, you can use the same _semver range_ projext uses so `npm`/`yarn` can resolve them to the ones installed by projext.

**`babel.env`**

Custom settings that projext will use as base when generating the ones for the [`@babel/preset-env`](https://yarnpkg.com/en/package/@babel/preset-env).

**`babel.overwrites`**

Expand Down
141 changes: 71 additions & 70 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,73 +1,74 @@
{
"name": "projext",
"description": "Bundle and run your javascript project without configuring an specific module bundler.",
"homepage": "https://projextjs.com",
"version": "7.2.0",
"repository": "homer0/projext",
"author": "Leonardo Apiwan (@homer0) <me@homer0.com>",
"license": "MIT",
"dependencies": {
"wootils": "^2.6.5",
"jimple": "^1.5.0",
"fs-extra": "^8.1.0",
"extend": "^3.0.2",
"del": "^5.1.0",
"shelljs": "0.8.3",
"glob": "^7.1.5",
"commander": "^3.0.2",
"@babel/core": "7.6.4",
"@babel/cli": "7.6.4",
"@babel/plugin-proposal-class-properties": "7.5.5",
"@babel/plugin-proposal-decorators": "7.6.0",
"@babel/plugin-syntax-dynamic-import": "7.2.0",
"@babel/plugin-proposal-object-rest-spread": "7.6.2",
"@babel/plugin-transform-runtime": "7.6.2",
"@babel/preset-flow": "7.0.0",
"@babel/preset-typescript": "7.6.0",
"@babel/preset-env": "7.6.3",
"@babel/runtime": "7.6.3",
"watchpack": "^1.6.0",
"nodemon": "^1.19.4",
"prompt": "^1.0.0",
"dotenv": "^8.2.0",
"dotenv-expand": "^5.1.0"
},
"devDependencies": {
"eslint": "^6.5.1",
"eslint-plugin-homer0": "^2.0.1",
"jest-ex": "^6.1.1",
"jest-cli": "^24.9.0",
"jasmine-expect": "^4.0.3",
"minimatch": "^3.0.4",
"esdoc": "^1.1.0",
"esdoc-standard-plugin": "^1.0.0",
"esdoc-node": "1.0.4",
"leasot": "^8.3.0",
"coveralls": "^3.0.7",
"husky": "^3.0.9"
},
"engine-strict": true,
"engines": {
"node": ">=8.10.0",
"npm": ">=3.0.0"
},
"main": "src/index.js",
"bin": {
"projext": "./src/bin/projext",
"projext-cli": "./src/bin/projext-cli"
},
"husky": {
"hooks": {
"pre-commit": "./utils/hooks/pre-commit",
"post-merge": "./utils/hooks/post-merge"
}
},
"scripts": {
"test": "./utils/scripts/test",
"lint": "./utils/scripts/lint",
"lint:full": "./utils/scripts/lint-full",
"predocs": "./utils/scripts/docs-index",
"docs": "./utils/scripts/docs",
"todo": "./utils/scripts/todo"
"name": "projext",
"description": "Bundle and run your javascript project without configuring an specific module bundler.",
"homepage": "https://projextjs.com",
"version": "8.0.0",
"repository": "homer0/projext",
"author": "Leonardo Apiwan (@homer0) <me@homer0.com>",
"license": "MIT",
"dependencies": {
"wootils": "^3.0.1",
"jimple": "^1.5.0",
"fs-extra": "^8.1.0",
"extend": "^3.0.2",
"del": "^5.1.0",
"shelljs": "0.8.3",
"glob": "^7.1.6",
"commander": "^4.0.1",
"@babel/core": "7.7.7",
"@babel/cli": "7.7.7",
"@babel/plugin-proposal-class-properties": "7.7.4",
"@babel/plugin-proposal-decorators": "7.7.4",
"@babel/plugin-syntax-dynamic-import": "7.7.4",
"@babel/plugin-proposal-object-rest-spread": "7.7.7",
"@babel/plugin-transform-runtime": "7.7.6",
"@babel/preset-flow": "7.7.4",
"@babel/preset-typescript": "7.7.7",
"@babel/preset-env": "7.7.7",
"@babel/runtime": "7.7.7",
"watchpack": "^1.6.0",
"nodemon": "^2.0.2",
"prompt": "^1.0.0",
"dotenv": "^8.2.0",
"dotenv-expand": "^5.1.0",
"core-js": "^3.6.1",
"regenerator-runtime": "0.13.3"
},
"devDependencies": {
"eslint": "^6.8.0",
"eslint-plugin-homer0": "^3.0.0",
"jest-ex": "^7.0.1",
"jest-cli": "^24.9.0",
"jasmine-expect": "^4.0.3",
"minimatch": "^3.0.4",
"esdoc": "^1.1.0",
"esdoc-standard-plugin": "^1.0.0",
"esdoc-node": "1.0.4",
"leasot": "^9.3.1",
"coveralls": "^3.0.9",
"husky": "^3.1.0"
},
"engine-strict": true,
"engines": {
"node": ">=10.13.0"
},
"main": "src/index.js",
"bin": {
"projext": "./src/bin/projext",
"projext-cli": "./src/bin/projext-cli"
},
"husky": {
"hooks": {
"pre-commit": "./utils/hooks/pre-commit",
"post-merge": "./utils/hooks/post-merge"
}
},
"scripts": {
"test": "./utils/scripts/test",
"lint": "./utils/scripts/lint",
"lint:full": "./utils/scripts/lint-full",
"predocs": "./utils/scripts/docs-index",
"docs": "./utils/scripts/docs",
"todo": "./utils/scripts/todo"
}
}
63 changes: 42 additions & 21 deletions src/services/cli/cliSHBuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,11 @@ class CLISHBuildCommand extends CLICommand {
* This method emits the event reducer `build-target-commands-list` with the list of commands,
* the target information, the type of build and whether or not the target should be executed;
* and it expects a list of commands on return.
* @param {?string} name The name of the target.
* @param {Command} command The executed command (sent by `commander`).
* @param {Object} options The command options.
* @param {string} options.type The type of build.
* @param {boolean} options.run Whether or not the target also needs to be executed.
* @param {boolean} options.watch Whether or not the target files will be watched.
* @param {boolean} options.inspect Whether or not the target will be inspected.
* @param {Object} unknownOptions A dictionary of extra options that command may have received.
* @param {?string} name The name of the target.
* @param {Command} command The executed command (sent by `commander`).
* @param {CLIBuildCommandOptions} options The command options.
* @param {Object} unknownOptions A dictionary of extra options that command may
* have received.
*/
handle(name, command, options, unknownOptions) {
const { type } = options;
Expand All @@ -193,25 +190,20 @@ class CLISHBuildCommand extends CLICommand {
// Get the default target or throw an error if the project doesn't have targets.
this.targets.getDefaultTarget();

// Check if there's a reason to analyze the target bundle.
const analyze = options.analyze && (target.is.browser || target.bundle);
// Check if there's a reason for the target to be executed.
const run = !analyze && type === 'development' && (target.runOnDevelopment || options.run);
// Check if there's a reason for the Node inspector to be enabled.
const inspect = run && target.is.node && (target.inspect.enabled || options.inspect);
// Check if the target files should be watched.
const watch = !run && (target.watch[type] || options.watch);
const {
development,
analyze,
run,
inspect,
watch,
} = this._normalizeOptions(options, target);
/**
* Check whether or not a build will be created. This is always `true` for browser targets, but
* it can be `false` for Node targets if bundling and transpiling is disabled.
*/
let build = true;
if (target.is.node) {
build = (
type === 'production' ||
target.bundle ||
target.transpile
);
build = !development || target.bundle || target.transpile;
}
// Define the parameters object to send to the other methods.
const params = {
Expand Down Expand Up @@ -240,6 +232,35 @@ class CLISHBuildCommand extends CLICommand {
// Outputs all the commands
this.output(output);
}
/**
* Normalizes the options received by the command in order to resolve "impossible combinations",
* like trying to analyze a target that is not for bundling or trying to inspect a browser
* target.
* @param {CLIBuildCommandOptions} options The command options.
* @param {Target} target The target information.
* @return {CLIBuildCommandNormalizedOptions}
* @access protected
* @ignore
*/
_normalizeOptions(options, target) {
const development = options.type === 'development';
// Check if there's a reason to analyze the target bundle.
const analyze = options.analyze && (target.is.browser || target.bundle);
// Check if there's a reason for the target to be executed.
const run = !analyze && development && (target.runOnDevelopment || options.run);
// Check if there's a reason for the Node inspector to be enabled.
const inspect = run && target.is.node && (target.inspect.enabled || options.inspect);
// Check if the target files should be watched.
const watch = !run && (target.watch[options.type] || options.watch);

return {
development,
analyze,
run,
inspect,
watch,
};
}
/**
* Get the build (and run) commands for a Node target.
* @param {CLIBuildCommandParams} params A dictionary with all the required information the
Expand Down
Loading