diff --git a/CHANGELOG.md b/CHANGELOG.md index d6a76063..84b2ad29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,41 @@ +## 0.6.0 (February 22, 2017) + +All enact-dev dependencies have been updated to latest applicable revisions. If you are using editor-based linting, please update your global dependencies to match. + +### create + +* Template updated for Enact 1.0.0-beta.3 and React 15.4.2. + +### pack + +* Transitioned from the iLib-loader to a new iLibPlugin with enhanced support for compilation-unique caching in Enact 1.0.0-beta.3. This is *not* backward compatible; please update to Enact 1.0.0-beta.3 or use an earlier release of enact-dev. +* Supports code splitting/lazy-loading via ES6 `import()` syntax (limited to static string values). +* WebOSMetaPlugin updated to support dynamicalling adding `usePrerendering:true` to appinfo.json files as needed. + +### test + +* Added Map polyfill support +* Fixes a code interaction issue with WebOSMetaPlugin that caused tests to fail. + +### lint + +* Enact ESLint plugin updated to support `handlers` block in `kind(). Also adds propType validation for props used by handler and computed functions. +* Enact ESLint config updated to replace deprecated `babel/array-bracket-spacing` with `array-bracket-spacing`. +* Additional options may be passed to the lint command. + ## 0.5.1 (January 27, 2017) -## create +### create * Template updated for Enact 1.0.0-beta.2 and React 15.4.2. * Template's .gitignore file now correctly includes `dist`. -## pack +### pack * Added a `node` Enact build option to support polyfilling NodeJS components. See [here](https://github.com/enyojs/enact-dev/blob/master/README.md#enact-build-options) for more info. * All localized appinfo.json resources and assets will now be correctly copied to the output directory. -# test +### test * Added a polyfill for String.prototype.repeat, as phantomjs lacks the API. * Webpack build warnings will no longer spam the console in certain scenarios. @@ -139,4 +164,4 @@ Several additional documentation files have been added to the `docs` directory, ## 0.1.0 (September 29, 2016) -* Initial internal release \ No newline at end of file +* Initial internal release diff --git a/README.md b/README.md index 63ec0dae..432fd0d4 100644 --- a/README.md +++ b/README.md @@ -95,8 +95,7 @@ You would need to install an ESLint plugin for your editor first. Then, you will need to install some packages *globally*: ```sh -npm install -g enyojs/eslint-config-enact eslint-plugin-react eslint-plugin-babel babel-eslint - +npm install -g eslint eslint-plugin-react eslint-plugin-babel babel-eslint enyojs/eslint-plugin-enact enyojs/eslint-config-enact ``` We recognize that this is suboptimal, but it is currently required due to the way we hide the ESLint dependency. The ESLint team is already [working on a solution to this](https://github.com/eslint/eslint/issues/3458) so this may become unnecessary in a couple of months. diff --git a/config/.babelrc b/config/.babelrc index e70fbf6b..50b581b5 100644 --- a/config/.babelrc +++ b/config/.babelrc @@ -1,6 +1,6 @@ { "presets": ["es2015", "stage-0", "react"], - "plugins": ["dev-expression"], + "plugins": ["dev-expression", "dynamic-import-webpack"], "env": { "production": { "plugins": ["transform-react-inline-elements","transform-react-constant-elements"] diff --git a/config/karma.conf.js b/config/karma.conf.js index 879bee57..7e430610 100644 --- a/config/karma.conf.js +++ b/config/karma.conf.js @@ -8,7 +8,7 @@ var autoprefixer = require('autoprefixer'); var LessPluginRi = require('resolution-independence'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); var GracefulFsPlugin = require('graceful-fs-webpack-plugin'); -var WebOSMetaPlugin = require('webos-meta-webpack-plugin'); +var ILibPlugin = require('ilib-webpack-plugin'); var CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); function readJSON(file) { @@ -29,6 +29,7 @@ module.exports = function(karma) { files: [ require.resolve('./polyfills'), require.resolve('string.prototype.repeat'), + require.resolve('es6-map/implement'), require.resolve('./proptype-checker'), './!(node_modules|dist|build)/**/*-specs.js' ], @@ -38,6 +39,7 @@ module.exports = function(karma) { './!(node_modules|dist|build)/**/*.js': ['webpack'], [require.resolve('./polyfills')]: ['webpack'], [require.resolve('string.prototype.repeat')]: ['webpack'], + [require.resolve('es6-map/implement')]: ['webpack'], [require.resolve('./proptype-checker')]: ['webpack'] }, @@ -96,8 +98,7 @@ module.exports = function(karma) { {test: /\.(c|le)ss$/, loader: ExtractTextPlugin.extract('style', 'css?-autoprefixer&modules&sourceMap&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss!less?sourceMap') }, - {test: /ilibmanifest\.json$/, loader: 'ilib?noSave'}, - {test: /\.json$/, loader: 'json', exclude: /ilibmanifest\.json$/}, + {test: /\.json$/, loader: 'json'}, {test: /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/, loader: 'file', query: { name: '[path][name].[ext]' @@ -128,7 +129,7 @@ module.exports = function(karma) { new ExtractTextPlugin('[name].css'), new CaseSensitivePathsPlugin(), new GracefulFsPlugin(), - new WebOSMetaPlugin() + new ILibPlugin({create: false}) ] }, diff --git a/config/webpack.config.dev.js b/config/webpack.config.dev.js index a1c34d20..0017a871 100644 --- a/config/webpack.config.dev.js +++ b/config/webpack.config.dev.js @@ -18,6 +18,7 @@ var LessPluginRi = require('resolution-independence'); var HtmlWebpackPlugin = require('html-webpack-plugin'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); var GracefulFsPlugin = require('graceful-fs-webpack-plugin'); +var ILibPlugin = require('ilib-webpack-plugin'); var WebOSMetaPlugin = require('webos-meta-webpack-plugin'); var CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); var WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin'); @@ -145,17 +146,11 @@ module.exports = { 'css?-autoprefixer&modules&sourceMap&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss!less?sourceMap') // Note: this won't work without `new ExtractTextPlugin()` in `plugins`. }, - // Support importing ilib bundles. - { - test: /ilibmanifest\.json$/, - loader: 'ilib' - }, // JSON is not enabled by default in Webpack but both Node and Browserify // allow it implicitly so we also enable it. { test: /\.json$/, - loader: 'json', - exclude: /ilibmanifest\.json$/ + loader: 'json' }, // "file" loader makes sure those assets get copied during build // When you `import` an asset, you get its output filename. @@ -248,6 +243,10 @@ module.exports = { // EMFILE errors when hanndling mass amounts of files at once, such as // what happens when using ilib bundles/resources. new GracefulFsPlugin(), + // Automatically configure iLib library within @enact/i18n. Additionally, + // ensure the locale data files and the resource files are copied during + // the build to the output directory. + new ILibPlugin(), // Automatically detect ./appinfo.json and ./webos-meta/appinfo.json files, // and parses any to copy over any webOS meta assets at build time. new WebOSMetaPlugin() diff --git a/config/webpack.config.prod.js b/config/webpack.config.prod.js index bc90acf9..1264ccf4 100644 --- a/config/webpack.config.prod.js +++ b/config/webpack.config.prod.js @@ -18,6 +18,7 @@ var LessPluginRi = require('resolution-independence'); var HtmlWebpackPlugin = require('html-webpack-plugin'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); var GracefulFsPlugin = require('graceful-fs-webpack-plugin'); +var ILibPlugin = require('ilib-webpack-plugin'); var WebOSMetaPlugin = require('webos-meta-webpack-plugin'); function readJSON(file) { @@ -130,17 +131,11 @@ module.exports = { 'css?-autoprefixer&modules&importLoaders=1!postcss!less') // Note: this won't work without `new ExtractTextPlugin()` in `plugins`. }, - // Support importing ilib bundles. - { - test: /ilibmanifest\.json$/, - loader: 'ilib' - }, // JSON is not enabled by default in Webpack but both Node and Browserify // allow it implicitly so we also enable it. { test: /\.json$/, - loader: 'json', - exclude: /ilibmanifest\.json$/ + loader: 'json' }, // "file" loader makes sure those assets get copied during build // When you `import` an asset, you get its output filename. @@ -246,6 +241,10 @@ module.exports = { // EMFILE errors when hanndling mass amounts of files at once, such as // what happens when using ilib bundles/resources. new GracefulFsPlugin(), + // Automatically configure iLib library within @enact/i18n. Additionally, + // ensure the locale data files and the resource files are copied during + // the build to the output directory. + new ILibPlugin(), // Automatically detect ./appinfo.json and ./webos-meta/appinfo.json files, // and parses any to copy over any webOS meta assets at build time. new WebOSMetaPlugin() diff --git a/docs/index.md b/docs/index.md index 0a6fa341..5f8f1820 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,8 +1,8 @@ --- -title: enact-dev +title: enact-dev Command Line Tool --- -The enact-dev package includes the following documentation: +The enact-dev package provides a command-line tool for creating and building Enact applications. The following sections describe its installation and use: * [Installation](./installation.md) * [Starting a New App](./starting-a-new-app.md) diff --git a/global-cli/lint.js b/global-cli/lint.js index c439ba39..3de5d0f2 100755 --- a/global-cli/lint.js +++ b/global-cli/lint.js @@ -19,7 +19,7 @@ function displayHelp() { process.exit(0); } -module.exports = function(args) { +module.exports = function (args) { var opts = minimist(args, { boolean: ['l', 'local', 's', 'strict', 'f', 'framework', 'h', 'help'], alias: {l:'local', s:'strict', f:'framework', h:'help'} @@ -27,17 +27,21 @@ module.exports = function(args) { opts.help && displayHelp(); var eslintArgs = []; - if(opts.strict || opts.framework) { + if (opts.strict || opts.framework) { eslintArgs.push('--no-eslintrc', '--config', require.resolve('eslint-config-enact/strict')); - } else if(!opts.local) { + } else if (!opts.local) { eslintArgs.push('--no-eslintrc', '--config', require.resolve('eslint-config-enact')); } eslintArgs.push('--ignore-pattern', 'node_modules/*'); eslintArgs.push('--ignore-pattern', 'build/*'); eslintArgs.push('--ignore-pattern', 'dist/*'); - eslintArgs.push(opts._[0] || '.'); + if (opts._.length) { + eslintArgs = eslintArgs.concat(opts._); + } else { + eslintArgs.push('.'); + } var child = cp.fork(require.resolve('eslint/bin/eslint'), eslintArgs, {env:process.env, cwd:process.cwd()}); - child.on('close', function(code, signal) { + child.on('close', function (code, signal) { process.exit(code); }); }; diff --git a/global-cli/modifiers/externals.js b/global-cli/modifiers/externals.js index c5d282b3..452870b1 100644 --- a/global-cli/modifiers/externals.js +++ b/global-cli/modifiers/externals.js @@ -4,15 +4,6 @@ var EnactFrameworkRefPlugin = require('./util/EnactFrameworkRefPlugin'); module.exports = function(config, opts) { - var resBundle = './resources/ilibmanifest.json'; - if(!exists(resBundle)) { - if(!exists('./resources')) { - fs.mkdirSync('./resources'); - } - fs.writeFileSync(resBundle, JSON.stringify({files:[]}, null, '\t'), {encoding:'utf8'}); - } - config.entry.main.splice(config.entry.main.length-1, 0, resBundle); - // Add the reference plugin so the app uses the external framework config.plugins.push(new EnactFrameworkRefPlugin({ name: 'enact_framework', diff --git a/global-cli/modifiers/framework.js b/global-cli/modifiers/framework.js index 888a25b0..32e84507 100644 --- a/global-cli/modifiers/framework.js +++ b/global-cli/modifiers/framework.js @@ -32,10 +32,11 @@ module.exports = function(config, opts) { config.output.library = 'enact_framework'; config.output.libraryTarget = 'umd'; - // Append additional options to the ilib-loader to skip './resources' detection/generation - var ilibLoader = helper.getLoaderByName(config, 'ilib'); - if(ilibLoader) { - ilibLoader.loader += '?noResources'; + // Modify the iLib plugin options to skip './resources' detection/generation + var ilibPlugin = helper.getPluginByName(config, 'ILibPlugin'); + if(ilibPlugin) { + ilibPlugin.options.create = false; + ilibPlugin.options.resources = false; } // Remove the HTML generation plugin and webOS-meta plugin diff --git a/global-cli/modifiers/isomorphic.js b/global-cli/modifiers/isomorphic.js index 6a4abc64..035add2c 100644 --- a/global-cli/modifiers/isomorphic.js +++ b/global-cli/modifiers/isomorphic.js @@ -28,7 +28,7 @@ module.exports = function(config, opts) { } // Prepend react-dom as top level entrypoint so espose-loader will expose // it to window.ReactDOM to allow runtime rendering of the app. - config.entry.main.unshift(reactDOM); + config.entry.main.splice(-1, 0, reactDOM); // Expose the 'react-dom' on a global context for App's rendering // Currently maps the toolset to window.ReactDOM. diff --git a/global-cli/modifiers/snapshot.js b/global-cli/modifiers/snapshot.js index 0a048e08..3bd3bd4f 100644 --- a/global-cli/modifiers/snapshot.js +++ b/global-cli/modifiers/snapshot.js @@ -1,6 +1,7 @@ var path = require('path'), fs = require('fs'), + exists = require('path-exists').sync, helper = require('./util/config-helper'), SnapshotPlugin = require('./util/SnapshotPlugin'); @@ -12,6 +13,14 @@ module.exports = function(config, opts) { htmlPlugin.options.snapshot = true; } + // fallback alias for fbjs in Node 4.x dependency tree + var fbjs = path.join(process.cwd(), 'node_modules', 'react', 'node_modules', 'fbjs'); + if(exists(fbjs)) { + config.resolve.alias.fbjs = fbjs; + } + // Snapshot helper API for the transition from v8 snapshot into the window + config.entry.main.splice(-1, 0, require.resolve('./util/snapshot-helper')); + // Expose iLib locale utility function module so we can update the locale on page load, if used var babel = helper.findLoader(config, 'babel'); config.module.loaders.splice((babel>=0 ? babel : 0), 0, { diff --git a/global-cli/modifiers/util/html-template-isomorphic.ejs b/global-cli/modifiers/util/html-template-isomorphic.ejs index dbcf19bd..fb951fab 100644 --- a/global-cli/modifiers/util/html-template-isomorphic.ejs +++ b/global-cli/modifiers/util/html-template-isomorphic.ejs @@ -31,7 +31,7 @@
diff --git a/global-cli/modifiers/util/snapshot-helper.js b/global-cli/modifiers/util/snapshot-helper.js new file mode 100644 index 00000000..411fbfc5 --- /dev/null +++ b/global-cli/modifiers/util/snapshot-helper.js @@ -0,0 +1,18 @@ +/* + * snapshot-helper.js + * + * Since the initial ExecutionEnvironment is set during snapshot creation, we need to provide an API + * to update environment on window load. + * + */ + +global.updateEnvironment = function() { + var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment'); + var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); + + ExecutionEnvironment.canUseDOM = canUseDOM; + ExecutionEnvironment.canUseWorkers = typeof Worker !== 'undefined'; + ExecutionEnvironment.canUseEventListeners = canUseDOM && !!(window.addEventListener || window.attachEvent); + ExecutionEnvironment.canUseViewport = canUseDOM && !!window.screen; + ExecutionEnvironment.isInWorker = !canUseDOM; // For now, this is true - might change in the future. +}; diff --git a/package.json b/package.json index 359e1d11..86901ade 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "enact-dev", - "version": "0.5.0", + "version": "0.6.0", "description": "Full-featured build environment for Enact applications.", "main": "index.js", "author": "Jason Robitaille ", @@ -10,45 +10,47 @@ "enact": "./bin/enact.js" }, "dependencies": { - "autoprefixer": "~6.5.4", - "babel-core": "~6.21.0", + "autoprefixer": "~6.7.3", + "babel-core": "~6.23.1", "babel-eslint": "~7.1.1", - "babel-loader": "~6.2.10", + "babel-loader": "~6.3.2", "babel-plugin-dev-expression": "~0.2.1", - "babel-plugin-transform-react-constant-elements": "~6.9.1", - "babel-plugin-transform-react-inline-elements": "~6.8.0", - "babel-preset-es2015": "~6.18.0", - "babel-preset-react": "~6.16.0", - "babel-preset-stage-0": "~6.16.0", + "babel-plugin-dynamic-import-webpack": "~1.0.1", + "babel-plugin-transform-react-constant-elements": "~6.23.0", + "babel-plugin-transform-react-inline-elements": "~6.22.0", + "babel-preset-es2015": "~6.22.0", + "babel-preset-react": "~6.23.0", + "babel-preset-stage-0": "~6.22.0", "case-sensitive-paths-webpack-plugin": "~1.1.4", "chai": "~3.5.0", "chalk": "~1.1.3", "connect-history-api-fallback": "~1.3.0", "cross-spawn": "~5.0.1", "css-loader": "~0.26.1", - "detect-port": "~1.0.7", + "detect-port": "~1.1.0", "dirty-chai": "~1.2.2", "enyo-console-spy": "enyojs/enyo-console-spy", - "enzyme": "~2.6.0", - "eslint": "~3.12.2", - "eslint-config-enact": "enyojs/eslint-config-enact#1.1.1", + "enzyme": "~2.7.1", + "es6-map": "~0.1.4", + "eslint": "~3.15.0", + "eslint-config-enact": "enyojs/eslint-config-enact#1.1.2", "eslint-loader": "~1.6.1", - "eslint-plugin-babel": "~4.0.0", - "eslint-plugin-enact": "enyojs/eslint-plugin-enact#0.1.0", - "eslint-plugin-react": "~6.8.0", - "expose-loader": "~0.7.1", + "eslint-plugin-babel": "~4.0.1", + "eslint-plugin-enact": "enyojs/eslint-plugin-enact#0.1.1", + "eslint-plugin-react": "~6.10.0", + "expose-loader": "~0.7.3", "extract-text-webpack-plugin": "~1.0.1", - "file-loader": "~0.9.0", - "filesize": "~3.3.0", + "file-loader": "~0.10.0", + "filesize": "~3.5.4", "find-cache-dir": "~0.1.1", - "fs-extra": "~1.0.0", + "fs-extra": "~2.0.0", "glob": "~7.1.1", "graceful-fs-webpack-plugin": "enyojs/graceful-fs-webpack-plugin#0.1.0", - "html-webpack-plugin": "~2.24.1", + "html-webpack-plugin": "~2.28.0", "http-proxy-middleware": "~0.17.3", - "ilib-loader": "enyojs/ilib-loader#0.1.1", + "ilib-webpack-plugin": "enyojs/ilib-webpack-plugin#0.1.1", "json-loader": "~0.5.4", - "karma": "~1.3.0", + "karma": "~1.4.1", "karma-babel-preprocessor": "~6.0.1", "karma-chai": "~0.1.0", "karma-chrome-launcher": "~2.0.0", @@ -57,25 +59,25 @@ "karma-mocha": "~1.3.0", "karma-phantomjs-launcher": "~1.0.2", "karma-sourcemap-loader": "~0.3.7", - "karma-webpack": "~1.8.0", - "less": "~2.7.1", + "karma-webpack": "~2.0.2", + "less": "~2.7.2", "less-loader": "~2.2.3", "minimist": "~1.2.0", "mocha": "~3.2.0", "ncp": "~2.0.0", "node-fetch": "~1.6.3", - "object-assign": "~4.1.0", + "object-assign": "~4.1.1", "path-exists": "~3.0.0", "phantomjs-prebuilt": "~2.1.14", - "postcss-loader": "~1.2.1", - "postcss-remove-classes": "~1.0.2", + "postcss-loader": "~1.3.0", + "postcss-remove-classes": "~1.0.4", "promise": "~7.1.1", "react": "~15.4.2", "react-addons-perf": "~15.4.2", "react-addons-test-utils": "~15.4.2", - "react-dev-utils": "~0.4.2", + "react-dev-utils": "~0.5.0", "react-dom": "~15.4.2", - "recursive-readdir": "~2.1.0", + "recursive-readdir": "~2.1.1", "require-from-string": "~1.2.1", "resolution-independence": "~0.0.3", "rimraf": "~2.5.4", @@ -86,10 +88,10 @@ "string.prototype.repeat": "~0.2.0", "strip-ansi": "~3.0.1", "style-loader": "~0.13.1", - "webos-meta-webpack-plugin": "enyojs/webos-meta-webpack-plugin#0.2.0", + "webos-meta-webpack-plugin": "enyojs/webos-meta-webpack-plugin#0.2.1", "webpack": "~1.14.0", - "webpack-bundle-analyzer": "~2.1.1", - "webpack-dev-server": "~1.16.2", - "whatwg-fetch": "~2.0.1" + "webpack-bundle-analyzer": "~2.3.0", + "webpack-dev-server": "~1.16.3", + "whatwg-fetch": "~2.0.2" } } diff --git a/template/package.json b/template/package.json index fbe2bae0..302c7782 100644 --- a/template/package.json +++ b/template/package.json @@ -28,12 +28,12 @@ "extends": "enact" }, "dependencies": { - "@enact/core": "^1.0.0-beta.2", - "@enact/ui": "^1.0.0-beta.2", - "@enact/moonstone": "^1.0.0-beta.2", - "@enact/spotlight": "^1.0.0-beta.2", - "@enact/i18n": "^1.0.0-beta.2", - "@enact/webos": "^1.0.0-beta.2", + "@enact/core": "^1.0.0-beta.3", + "@enact/ui": "^1.0.0-beta.3", + "@enact/moonstone": "^1.0.0-beta.3", + "@enact/spotlight": "^1.0.0-beta.3", + "@enact/i18n": "^1.0.0-beta.3", + "@enact/webos": "^1.0.0-beta.3", "react": "^15.4.2", "react-dom": "^15.4.2" }