Skip to content

Commit 62f2c20

Browse files
committed
Release 11.1.0
1 parent 7f3a891 commit 62f2c20

13 files changed

+144
-88
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# @oracle/oraclejet-tooling 11.0.0
1+
# @oracle/oraclejet-tooling 11.1.0
22

33
## About the tooling API
44
This tooling API contains methods to build and serve Oracle JET web and hybrid mobile apps. It is intended to be used with task running tools such as grunt or gulp. The APIs can also be invoked directly.
55

66
This is an open source project maintained by Oracle Corp.
77

88
## Installation
9-
This module will be automatically installed when you scaffold a web or hybrid mobile app following the [Oracle JET Developers Guide](http://www.oracle.com/pls/topic/lookup?ctx=jet1100&id=homepage).
9+
This module will be automatically installed when you scaffold a web or hybrid mobile app following the [Oracle JET Developers Guide](http://www.oracle.com/pls/topic/lookup?ctx=jet1110&id=homepage).
1010

1111
## [Contributing](https://github.com/oracle/oraclejet-tooling/blob/master/CONTRIBUTING.md)
1212
Oracle JET is an open source project. Pull Requests are currently not being accepted. See

RELEASENOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Release Notes for oraclejet-tooling ##
22

3-
### 11.0.0
3+
### 11.1.0
44
* oraclejet-tooling now requires node 12.21 or later
55

66
### 5.2.0

lib/addwebpack.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const exec = require('child_process').exec;
1616
function updateOraclejetConfig() {
1717
return new Promise((resolve) => {
1818
util.log('Adding bundler and bundlerName properties to oraclejetconfig.json');
19-
const oraclejetConfigJson = util.readJsonAndReturnObject(CONSTANTS.ORACLE_JET_CONFIG_JSON);
19+
const oraclejetConfigJson = util.getOraclejetConfigJson();
2020
oraclejetConfigJson.bundler = 'webpack';
2121
oraclejetConfigJson.bundleName = CONSTANTS.DEFAULT_BUNDLE_NAME;
2222
util.writeObjectAsJsonFile(CONSTANTS.ORACLE_JET_CONFIG_JSON, oraclejetConfigJson);
@@ -31,7 +31,7 @@ function updateOraclejetConfig() {
3131
function installWebpack() {
3232
return new Promise((resolve) => {
3333
util.log('Installing webpack and required loaders');
34-
exec('npm i -D webpack text-loader style-loader css-loader', {
34+
exec(`npm i -D webpack@${CONSTANTS.WEBPACK_VERSION} text-loader@${CONSTANTS.TEXT_LOADER_VERSION} style-loader@${CONSTANTS.STYLE_LOADER_VERSION} css-loader@${CONSTANTS.CSS_LOADER_VERSION} --save-dev --save-exact`, {
3535
env: {
3636
...process.env,
3737
// speed up npm install when on vpn

lib/buildCommon.js

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,21 @@ function _isSvgFile(fileName) {
5151
return path.extname(fileName) === '.svg';
5252
}
5353

54+
function _getThemePlatform(themePlatform, themeName) {
55+
// No platform other than web for redwood, stable themes
56+
return (themeName !== CONSTANTS.DEFAULT_PCSS_THEME && themeName !== CONSTANTS.DEFAULT_STABLE_THEME) ? themePlatform : 'web';
57+
}
58+
5459
function _getThemeSrcPath(theme) {
55-
return `${config('paths').staging.themes}/${theme.name}/${theme.platform}`;
60+
const themePlatform = _getThemePlatform(theme.platform, theme.name);
61+
return `${config('paths').staging.themes}/${theme.name}/${themePlatform}`;
5662
}
5763

5864
function _getThemeDestPath(theme, stagingPath, ext, cssonly, servePlatform, serveDestination) {
5965
let dest;
6066
let base;
6167
const stylePath = config('paths').src.styles;
68+
const themePlatform = _getThemePlatform(theme.platform, theme.name);
6269
if (cssonly) {
6370
if (servePlatform === 'web') {
6471
base = path.resolve(stagingPath);
@@ -69,9 +76,9 @@ function _getThemeDestPath(theme, stagingPath, ext, cssonly, servePlatform, serv
6976
} else {
7077
base = path.resolve(stagingPath, '..', 'platforms', servePlatform, 'app/src/main/assets', 'www');
7178
}
72-
dest = util.destPath(path.join(base, stylePath, theme.name, theme.version, theme.platform, '/'));
79+
dest = util.destPath(path.join(base, stylePath, theme.name, theme.version, themePlatform, '/'));
7380
} else {
74-
dest = util.destPath(path.join(stagingPath, stylePath, theme.name, theme.version, theme.platform, '/'));
81+
dest = util.destPath(path.join(stagingPath, stylePath, theme.name, theme.version, themePlatform, '/'));
7582
}
7683
return dest;
7784
}
@@ -101,23 +108,22 @@ function _copyDefaultResourcesToStaging(theme, stagingPath, themeName) {
101108
const srcBase = `${config('paths').staging.themes}/${themeName}`;
102109
const destBase = util.destPath(path.join(stagingPath, config('paths').src.styles, themeName, util.getJETVersion()));
103110

104-
const defaultFontsSrc = path.join(srcBase, theme.platform, 'fonts');
105-
const defaultImagesSrc = path.join(srcBase, theme.platform, 'images');
106-
107-
const defaultFontsDest = path.join(destBase, theme.platform, 'fonts');
108-
const defaultImagesDest = path.join(destBase, theme.platform, 'images');
111+
const themePlatform = _getThemePlatform(theme.platform, themeName);
112+
const defaultFontsSrc = path.join(srcBase, themePlatform, 'fonts');
113+
const defaultImagesSrc = path.join(srcBase, themePlatform, 'images');
109114

115+
const defaultFontsDest = path.join(destBase, themePlatform, 'fonts');
116+
const defaultImagesDest = path.join(destBase, themePlatform, 'images');
110117
if (config('defaultTheme') === CONSTANTS.DEFAULT_THEME && themeName !== CONSTANTS.DEFAULT_PCSS_THEME && themeName !== CONSTANTS.DEFAULT_STABLE_THEME) {
111118
const commonSrc = path.join(srcBase, CONSTANTS.COMMON_THEME_DIRECTORY);
112119
const commonDest = path.join(destBase, CONSTANTS.COMMON_THEME_DIRECTORY);
113120
fs.copySync(commonSrc, commonDest);
114121
}
115-
116122
fs.copySync(defaultFontsSrc, defaultFontsDest);
117123
fs.copySync(defaultImagesSrc, defaultImagesDest);
118124
}
119125

120-
function _copyComponentsToStaging(componentsSource) {
126+
function _copyExchangeComponentsToStaging({ context, componentsSource }) {
121127
return new Promise((resolve) => {
122128
if (util.isObjectEmpty(componentsSource)) {
123129
// No component source present, continue...
@@ -132,11 +138,15 @@ function _copyComponentsToStaging(componentsSource) {
132138
componentDirPath, CONSTANTS.JET_COMPONENT_JSON);
133139
if (fs.existsSync(componentJsonPath)) {
134140
const componentJson = util.readJsonAndReturnObject(componentJsonPath);
135-
const destBase = path.join(config('paths').staging.stagingPath, config('paths').src.javascript, config('paths').components);
136141
if (!util.hasProperty(componentJson, 'version')) {
137142
util.log.error(`Missing property 'version' in '${component}' component's/pack's definition file.`);
138143
}
139-
const destPath = path.join(destBase, component, componentJson.version);
144+
const destPath = util.generatePathToComponentRoot({
145+
context,
146+
component,
147+
root: context.opts.stagingPath,
148+
scripts: configPaths.src.javascript
149+
});
140150
fs.copySync(componentDirPath, destPath);
141151
resolve();
142152
} else {
@@ -175,8 +185,10 @@ function _copySrcResourcesToThemes(theme) {
175185
const srcBase = `${config('paths').src.common}/${config('paths').src.themes}/${theme.name}`;
176186
const destBase = util.destPath(path.join(config('paths').staging.themes, theme.name));
177187
const srcCommon = path.join(srcBase, CONSTANTS.COMMON_THEME_DIRECTORY);
188+
const themePlatform = _getThemePlatform(theme.platform, theme.name);
189+
178190
_copyFilesExcludeScss(srcCommon, path.join(destBase, CONSTANTS.COMMON_THEME_DIRECTORY));
179-
_copyFilesExcludeScss(path.join(srcBase, theme.platform), path.join(destBase, theme.platform));
191+
_copyFilesExcludeScss(path.join(srcBase, themePlatform), path.join(destBase, themePlatform));
180192
}
181193

182194
function _copyMultiThemesSrcResourcesToThemes(themes) {
@@ -192,8 +204,10 @@ function _copyMultiThemesToStaging(opts, stagingPath, livereload) {
192204
const srcBase = config('paths').staging.themes;
193205
opts.themes.forEach((singleTheme) => {
194206
// copy css
195-
const src = path.join(srcBase, singleTheme.name, singleTheme.platform);
196-
const dest = util.destPath(path.join(stagingPath, config('paths').src.styles, singleTheme.name, singleTheme.version, singleTheme.platform, '/'));
207+
const themePlatform = _getThemePlatform(singleTheme.platform, singleTheme.name);
208+
209+
const src = path.join(srcBase, singleTheme.name, themePlatform);
210+
const dest = util.destPath(path.join(stagingPath, config('paths').src.styles, singleTheme.name, singleTheme.version, themePlatform, '/'));
197211
fs.copySync(src, dest);
198212

199213
// copy common dir
@@ -217,25 +231,23 @@ function _copyThemesToStaging(context) {
217231
// copy the entire theme/platform folder during build
218232
const ext = util.getThemeCssExtention(buildType);
219233
const src = _getThemeSrcPath(theme, ext, livereload);
234+
220235
const dest = _getThemeDestPath(theme, stgPath, ext, livereload, platform, opts.destination);
221236
const rwood = Object.assign({},
222-
{ name: 'redwood', platform: 'web', compile: false, version: util.getJETVersion() },
223-
{ name: 'stable', platform: 'web', compile: false, version: util.getJETVersion() });
224-
225-
if (opts.theme.cssGeneratedType === 'add-on' || (config('defaultTheme') === CONSTANTS.DEFAULT_PCSS_THEME || config('defaultTheme') === CONSTANTS.DEFAULT_STABLE_THEME)) {
237+
{ name: 'redwood', platform: 'web', compile: false, version: util.getJETVersion() });
238+
if (opts.theme.cssGeneratedType === 'add-on' && opts.theme.basetheme === CONSTANTS.DEFAULT_PCSS_THEME) {
226239
const rwsrc = _getThemeSrcPath(rwood, ext, livereload);
227240
const rwdest = _getThemeDestPath(rwood, stgPath, ext, livereload, platform, opts.destination);
228241
fs.copySync(rwsrc, rwdest);
229242
}
230243

231244
const stable = Object.assign({},
232245
{ name: 'stable', platform: 'web', compile: false, version: util.getJETVersion() });
233-
if (opts.theme.cssGeneratedType === 'add-on' || (config('defaultTheme') === CONSTANTS.DEFAULT_PCSS_THEME || config('defaultTheme') === CONSTANTS.DEFAULT_STABLE_THEME)) {
246+
if (opts.theme.cssGeneratedType === 'add-on' && opts.theme.basetheme === CONSTANTS.DEFAULT_STABLE_THEME) {
234247
const stsrc = _getThemeSrcPath(stable, ext, livereload);
235248
const stdest = _getThemeDestPath(stable, stgPath, ext, livereload, platform, opts.destination);
236249
fs.copySync(stsrc, stdest);
237250
}
238-
239251
return new Promise((resolve, reject) => {
240252
// copy to themes
241253
if ((theme.name !== CONSTANTS.DEFAULT_THEME || theme.name !== CONSTANTS.DEFAULT_PCSS_THEME ||
@@ -407,7 +419,10 @@ module.exports = {
407419
const fileResult = util.getFileList(context.buildType, srcFileList);
408420

409421
return _copyFileToStaging(fileResult)
410-
.then(() => _copyComponentsToStaging(componentsSource[0]))
422+
.then(() => (_copyExchangeComponentsToStaging({
423+
context,
424+
componentsSource: componentsSource[0]
425+
})))
411426
.then(() => {
412427
util.log('Copy finished.');
413428
return context;

lib/buildCommon/minifyComponent.js

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,32 @@ class ComponentMinifier {
2929
);
3030
}
3131
getExtraEmpties() {
32-
const componentsCache = util.getComponentsCache();
3332
const extraEmpties = new Set();
3433
const { componentJson } = this;
35-
if (util.hasProperty(componentJson, 'dependencies')) {
36-
let componentCache;
37-
Object.keys(componentJson.dependencies).forEach((dependency) => {
38-
componentCache = componentsCache[dependency];
39-
if (componentCache) {
40-
if (componentCache.componentJson.type === 'pack') {
41-
util.log.error(`Cannot have a dependency on a pack (${dependency}).`);
34+
ComponentMinifier.addComponentDependenciesToExtraEmpties({ extraEmpties, componentJson });
35+
return Array.from(extraEmpties);
36+
}
37+
static addComponentDependenciesToExtraEmpties({ extraEmpties, componentJson }) {
38+
const DEPENDENCIES = 'dependencies';
39+
if (util.hasProperty(componentJson, DEPENDENCIES)) {
40+
const componentsCache = util.getComponentsCache();
41+
Object.keys(componentJson[DEPENDENCIES])
42+
.forEach((dependency) => {
43+
const componentCache = componentsCache[dependency];
44+
if (componentCache) {
45+
if (componentCache.componentJson.type === 'pack') {
46+
util.log.error(`Cannot have a dependency on a pack (${dependency}).`);
47+
} else {
48+
extraEmpties.add(componentCache.importName);
49+
extraEmpties.add(`${CONSTANTS.PATH_MAPPING_PREFIX_TOKEN}${componentCache.importName}`);
50+
}
4251
} else {
43-
extraEmpties.add(componentCache.importName);
44-
extraEmpties.add(`${CONSTANTS.PATH_MAPPING_PREFIX_TOKEN}${componentCache.importName}`);
52+
// eslint-disable-next-line prefer-template
53+
const output = `${dependency} is an invalid dependency in component ${componentJson.name}. Please make sure that it is available in your application.\ndependencies: ` + JSON.stringify(componentJson.dependencies);
54+
util.log.error(output);
4555
}
46-
} else {
47-
// eslint-disable-next-line prefer-template
48-
const output = `${dependency} is an invalid dependency in component ${componentJson.name}. Please make sure that it is available in your application.\ndependencies: ` + JSON.stringify(componentJson.dependencies);
49-
util.log.error(output);
50-
}
51-
});
56+
});
5257
}
53-
return Array.from(extraEmpties);
5458
}
5559
}
5660

@@ -172,7 +176,8 @@ class ResourceComponentMinifier extends PackComponentMinifier {
172176
context,
173177
rjsOptions: this.generateRjsOptions({ publicModule }),
174178
root: packName,
175-
extraExcludes: this.getExtraExcludes({ publicModule })
179+
extraExcludes: this.getExtraExcludes({ publicModule }),
180+
extraEmpties: this.getExtraEmpties()
176181
});
177182
});
178183
}
@@ -268,10 +273,36 @@ class PackBundlesMinifier extends ComponentMinifier {
268273
},
269274
root: packName,
270275
tempBundleFile,
276+
extraEmpties: this.getExtraEmpties(bundleKey)
271277
});
272278
});
273279
return config;
274280
}
281+
getExtraEmpties(bundleKey) {
282+
const extraEmpties = new Set();
283+
const componentsCache = util.getComponentsCache();
284+
const { packComponentJson } = this;
285+
// Loop through the list of bundle contents
286+
packComponentJson.bundles[bundleKey]
287+
.forEach((bundlePath) => {
288+
// Bundle paths are of the form <pack>/<component>/file. Use that
289+
// to construct the full component name for look up in the cache
290+
const [pack, component] = path.normalize(bundlePath).split(path.sep);
291+
const fullComponentName = `${pack}-${component}`;
292+
if (componentsCache[fullComponentName]) {
293+
// Check if the component being bundled has dependencies. If it does,
294+
// add them to the empty / exclusion list for the bundle. This makes
295+
// sure that r.js recognizes the dependencies when creating the bundle
296+
// and does not add their contents to the it.
297+
const { componentJson } = componentsCache[fullComponentName];
298+
ComponentMinifier.addComponentDependenciesToExtraEmpties({
299+
extraEmpties,
300+
componentJson
301+
});
302+
}
303+
});
304+
return Array.from(extraEmpties);
305+
}
275306
}
276307

277308
/**

lib/buildCommon/optimizeComponent.js

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function optimizeComponentSetup({
8080
separateCSS: context.opts.requireJsComponent.separateCSS,
8181
generateSourceMaps: context.opts.requireJsComponent.generateSourceMaps
8282
};
83-
const exclude = ['css', 'ojcss', 'ojL10n', 'text', 'normalize', 'css-builder'];
83+
const exclude = ['css', 'ojcss', 'ojs/ojcss', 'ojL10n', 'text', 'normalize', 'ojs/normalize', 'css-builder'];
8484
if (extraExcludes) {
8585
extraExcludes.forEach((extraExclude) => {
8686
pathMappings[extraExclude] = 'empty:';
@@ -186,24 +186,36 @@ async function ojcssPatchBeforeOptimize({ root, context }) {
186186
.substring(CONSTANTS.PATH_MAPPING_PREFIX_TOKEN.length);
187187
// Split path mapping by path seperator
188188
const pathMappingParts = path.normalize(unprefixedPathMapping).split(path.sep);
189-
// If split contains two entries, path mapping corresponds to a pack component. If
190-
// it contains one entry, path mapping corresponds to a singleton component
191-
const componentPath = pathMappingParts.length === 2 ?
192-
util.generatePathToComponentRoot({
193-
context,
194-
pack: pathMappingParts[0],
195-
component: pathMappingParts[1],
196-
root: context.opts.stagingPath,
197-
scripts: configPaths.src.javascript
198-
})
199-
:
200-
util.generatePathToComponentRoot({
201-
context,
202-
component: pathMappingParts[0],
203-
root: context.opts.stagingPath,
204-
scripts: configPaths.src.javascript
205-
});
206-
componentRequireJs.paths[prefixedPathMapping] = path.resolve(componentPath);
189+
let componentPath;
190+
if (pathMappingParts.length === 2) {
191+
// If split contains two entries and is a component, path mapping
192+
// corresponds to a pack component.
193+
const [pack, component] = pathMappingParts;
194+
componentPath = util.isWebComponent({ pack, component }) ?
195+
util.generatePathToComponentRoot({
196+
context,
197+
pack,
198+
component,
199+
root: context.opts.stagingPath,
200+
scripts: configPaths.src.javascript
201+
}) :
202+
null;
203+
} else if (pathMappingParts.length === 1) {
204+
// If split contains one entry and is a component, path mapping corresponds
205+
// to a singleton component.
206+
const [component] = pathMappingParts;
207+
componentPath = util.isWebComponent({ component }) ?
208+
util.generatePathToComponentRoot({
209+
context,
210+
component,
211+
root: context.opts.stagingPath,
212+
scripts: configPaths.src.javascript
213+
}) :
214+
null;
215+
}
216+
if (componentPath) {
217+
componentRequireJs.paths[prefixedPathMapping] = path.resolve(componentPath);
218+
}
207219
});
208220
// Check *.js files in the component folder for ojcss imports
209221
getJavascriptFilesInComponentFolder({ context })

lib/buildCommon/webpack.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ function _createConfig(context) {
4848
alias: {
4949
ojL10n: 'ojL10n-loader',
5050
text: 'text-loader',
51-
css: 'style-loader'
51+
css: 'style-loader',
52+
ojcss: 'style-loader'
5253
}
5354
},
5455
resolve: {

lib/constants.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,9 @@ module.exports = {
105105
WEBPACK_TOOLS_PATH: 'dist/webpack-tools',
106106
VDOM_ARCHITECTURE: 'vdom',
107107
DEFAULT_BUNDLE_NAME: 'bundle.js',
108-
PATH_MAPPING_PREFIX_TOKEN: '@'
108+
PATH_MAPPING_PREFIX_TOKEN: '#',
109+
WEBPACK_VERSION: '5.44.0',
110+
TEXT_LOADER_VERSION: '0.0.1',
111+
CSS_LOADER_VERSION: '6.0.0',
112+
STYLE_LOADER_VERSION: '3.1.0'
109113
};

0 commit comments

Comments
 (0)