diff --git a/CHANGELOG.md b/CHANGELOG.md index c2ba79f..34adb0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 2.4.2 (January 29, 2020) + +* `EnactFrameworkPlugin`: Added support for ilib inclusion in bundles. +* `EnactFrameworkRefPlugin`: Added support for `ignore` array option for package paths to handle internally, rather than deferred to external. +* `ILibPlugin`: Removed special handling for moonstone package and added generic constant support for root-level packages. + # 2.4.1 (September 4, 2019) * `SnapshotPlugin`: Fixed V8 snapshotting when `ilib` external package is not found. diff --git a/README.md b/README.md index 9f49c11..4f8c260 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Resolves the active package root path and metadata. Unless otherwise specified, all content, including all source code files and documentation files in this repository are: -Copyright (c) 2016-2019 LG Electronics +Copyright (c) 2016-2020 LG Electronics Unless otherwise specified or set forth in the NOTICE file, all content, including all source code files and documentation files in this repository are: diff --git a/mixins/externals.js b/mixins/externals.js index e5e23b7..973ee09 100644 --- a/mixins/externals.js +++ b/mixins/externals.js @@ -6,7 +6,7 @@ module.exports = { config.plugins.push( new EnactFrameworkRefPlugin({ name: 'enact_framework', - libraries: ['@enact', 'react', 'react-dom'], + libraries: ['@enact', 'react', 'react-dom', 'ilib'], external: { publicPath: opts['externals-public'] || opts.externalsPublic || opts.externals, snapshot: opts.snapshot diff --git a/mixins/framework.js b/mixins/framework.js index fdadc6b..52a2c6d 100644 --- a/mixins/framework.js +++ b/mixins/framework.js @@ -19,6 +19,9 @@ module.exports = { '**/build/**/*.*', '**/dist/**/*.*', '**/@enact/dev-utils/**/*.*', + '**/@enact/storybook-utils/**/*.*', + '**/@enact/ui-test-utils/**/*.*', + '**/@enact/screenshot-test-utils/**/*.*', '**/ilib/localedata/**/*.*', path.join(config.output.path, '*'), '**/node_modules/**/*.*', @@ -26,6 +29,20 @@ module.exports = { ], follow: true }) + .concat( + glob.sync('ilib/**/*.@(js|jsx|es6)', { + cwd: path.resolve(path.join(app, 'node_modules')), + nodir: true, + ignore: [ + '**/localedata/**/*.*', + '**/node_modules/**/*.*', + '**/ilib-node*.js', + '**/AsyncNodeLoader.js', + '**/NodeLoader.js' + ], + follow: true + }) + ) .concat(['react', 'react-dom']) }; diff --git a/mixins/unmangled.js b/mixins/unmangled.js index c6a114d..c3f34b4 100644 --- a/mixins/unmangled.js +++ b/mixins/unmangled.js @@ -5,7 +5,9 @@ module.exports = { // Allow Terser's optimizations/debug-code-removal but don't minify const terserPlugin = helper.getMinimizerByName(config, 'TerserPlugin'); if (terserPlugin) { + terserPlugin.options.terserOptions = terserPlugin.options.terserOptions || {}; terserPlugin.options.terserOptions.mangle = false; + terserPlugin.options.terserOptions.output = terserPlugin.options.terserOptions.output || {}; terserPlugin.options.terserOptions.output.beautify = true; terserPlugin.options.terserOptions.output.comments = true; config.output.pathinfo = true; diff --git a/package-lock.json b/package-lock.json index a81056d..764eb69 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@enact/dev-utils", - "version": "2.4.1", + "version": "2.4.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 47baef9..bd57685 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@enact/dev-utils", - "version": "2.4.1", + "version": "2.4.2", "description": "A collection of development utilities for Enact apps.", "main": "index.js", "author": "Jason Robitaille ", diff --git a/plugins/ILibPlugin/index.js b/plugins/ILibPlugin/index.js index 60edfd2..4330cc4 100644 --- a/plugins/ILibPlugin/index.js +++ b/plugins/ILibPlugin/index.js @@ -46,6 +46,17 @@ function transformPath(context, file) { .replace(/\.\.(\/)?/g, '_$1'); } +function bundleConst(name) { + return ( + 'ILIB_' + + path + .basename(name) + .toUpperCase() + .replace(/[-_\s]/g, '_') + + '_PATH' + ); +} + function resolveBundle(dir, context) { const bundle = {resolved: dir, path: dir, emit: true}; if (path.isAbsolute(bundle.path)) { @@ -185,11 +196,6 @@ class ILibPlugin { if (typeof this.options.resources === 'undefined') { this.options.resources = 'resources'; } - if ((!this.options.bundles || !this.options.bundles.moonstone) && pkgName === '@enact/moonstone') { - this.options.bundles = this.options.bundles || {}; - this.options.bundles.moonstone = 'resources'; - this.options.resources = '_resources_'; - } this.options.cache = typeof this.options.cache !== 'boolean' || this.options.cache; this.options.create = typeof this.options.create !== 'boolean' || this.options.create; @@ -224,15 +230,12 @@ class ILibPlugin { ILIB_RESOURCES_PATH: resolveBundle(opts.resources || 'resources', opts.context).resolved, ILIB_CACHE_ID: '__webpack_require__.ilib_cache_id' }; + definedConstants[bundleConst(app.name)] = definedConstants.ILIB_RESOURCES_PATH; for (const name in opts.bundles) { if (opts.bundles[name]) { const bundle = resolveBundle(opts.bundles[name], opts.context); const bundleManifest = path.join(bundle.path, 'ilibmanifest.json'); - const envName = path - .basename(name) - .toUpperCase() - .replace(/[-_\s]/g, '_'); - definedConstants['ILIB_' + envName + '_PATH'] = bundle.resolved; + definedConstants[bundleConst(name)] = bundle.resolved; if (opts.emit && bundle.emit && fs.existsSync(bundleManifest)) { manifests.push(bundleManifest); } diff --git a/plugins/dll/EnactFrameworkRefPlugin.js b/plugins/dll/EnactFrameworkRefPlugin.js index 6998422..4cb979b 100644 --- a/plugins/dll/EnactFrameworkRefPlugin.js +++ b/plugins/dll/EnactFrameworkRefPlugin.js @@ -14,11 +14,14 @@ class DelegatedEnactFactoryPlugin { apply(normalModuleFactory) { const name = this.options.name; const libReg = new RegExp('^(' + this.options.libraries.join('|') + ')(?=[\\\\\\/]|$)'); + const ignReg = + this.options.ignore && + new RegExp('^(' + this.options.ignore.map(p => p.replace('/', '\\/')).join('|') + ')(?=[\\\\\\/]|$)'); normalModuleFactory.hooks.factory.tap('DelegatedEnactFactoryPlugin', factory => { return function(data, callback) { const dependency = data.dependencies[0]; const request = dependency.request; - if (request && libReg.test(request)) { + if (request && libReg.test(request) && (!ignReg || !ignReg.test(request))) { return callback(null, new DelegatedModule(name, {id: request}, 'require', request, request)); } return factory(data, callback); @@ -51,6 +54,12 @@ class EnactFrameworkRefPlugin { this.options = options; this.options.name = this.options.name || 'enact_framework'; this.options.libraries = this.options.libraries || ['@enact', 'react', 'react-dom', 'ilib']; + this.options.ignore = this.options.ignore || [ + '@enact/dev-utils', + '@enact/storybook-utils', + '@enact/ui-test-utils', + '@enact/screenshot-test-utils' + ]; this.options.external = this.options.external || {}; this.options.external.publicPath = this.options.publicPath || this.options.external.publicPath || this.options.external.path; @@ -108,7 +117,8 @@ class EnactFrameworkRefPlugin { compiler.hooks.compile.tap('EnactFrameworkRefPlugin', ({normalModuleFactory}) => { new DelegatedEnactFactoryPlugin({ name: this.options.name, - libraries: this.options.libraries + libraries: this.options.libraries, + ignore: this.options.ignore }).apply(normalModuleFactory); }); }