liferay-npm-bundler-loader-css-loader
Advanced tools
Comparing version 2.13.2 to 2.13.3-alpha.6
158
lib/index.js
@@ -1,92 +0,82 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = function (context, _ref) { | ||
var extension = _ref.extension, | ||
_ref$pathModule = _ref.pathModule, | ||
pathModule = _ref$pathModule === undefined ? '/o' : _ref$pathModule; | ||
var filePath = context.filePath, | ||
log = context.log; | ||
var href = getHref(filePath, extension, pathModule); | ||
// Note that Liferay.ThemeDisplay.getPathContext() when called at runtime | ||
// returns both pathProxy and the context path of the portal's webapp. | ||
context.extraArtifacts[filePath + '.js.wrap-modules-amd.template'] = '\nvar link = document.createElement("link");\nlink.setAttribute("rel", "stylesheet");\nlink.setAttribute("type", "text/css");\nlink.setAttribute("href", Liferay.ThemeDisplay.getPathContext() + "' + href + '");\n\nfunction defineModule() {\n\t__WRAPPED_MODULE__\t\n}\n\nlink.onload = defineModule;\n\nlink.onerror = function() {\n\tconsole.warn(\'Unable to load ' + href + '. However, its .js module will still be defined to avoid breaking execution flow (expect some visual degradation).\');\n\n\tdefineModule();\n}\n\ndocument.querySelector("head").appendChild(link);\n'; | ||
context.extraArtifacts[filePath + '.js'] = '\nmodule.exports = link;\n'; | ||
log.info('css-loader', 'Generated .js module to inject \'' + href + '\''); | ||
"use strict"; | ||
/** | ||
* © 2017 Liferay, Inc. <https://liferay.com> | ||
* | ||
* SPDX-License-Identifier: LGPL-3.0-or-later | ||
*/ | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const fs_1 = __importDefault(require("fs")); | ||
const file_path_1 = __importDefault(require("liferay-npm-build-tools-common/lib/file-path")); | ||
const project_1 = __importDefault(require("liferay-npm-build-tools-common/lib/project")); | ||
const path_1 = __importDefault(require("path")); | ||
/** | ||
* @param {object} context loader's context | ||
*/ | ||
function default_1(context, { extension, pathModule = '/o' }) { | ||
const { filePath, log } = context; | ||
const href = getHref(filePath, extension, pathModule); | ||
// Note that Liferay.ThemeDisplay.getPathContext() when called at runtime | ||
// returns both pathProxy and the context path of the portal's webapp. | ||
context.extraArtifacts[`${filePath}.js.wrap-modules-amd.template`] = ` | ||
var link = document.createElement("link"); | ||
link.setAttribute("rel", "stylesheet"); | ||
link.setAttribute("type", "text/css"); | ||
link.setAttribute("href", Liferay.ThemeDisplay.getPathContext() + "${href}"); | ||
var _fs = require('fs'); | ||
function defineModule() { | ||
__WRAPPED_MODULE__ | ||
} | ||
var _fs2 = _interopRequireDefault(_fs); | ||
link.onload = defineModule; | ||
var _filePath = require('liferay-npm-build-tools-common/lib/file-path'); | ||
link.onerror = function() { | ||
console.warn('Unable to load ${href}. However, its .js module will still be defined to avoid breaking execution flow (expect some visual degradation).'); | ||
var _filePath2 = _interopRequireDefault(_filePath); | ||
defineModule(); | ||
} | ||
var _project = require('liferay-npm-build-tools-common/lib/project'); | ||
var _project2 = _interopRequireDefault(_project); | ||
var _path = require('path'); | ||
var _path2 = _interopRequireDefault(_path); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
document.querySelector("head").appendChild(link); | ||
`; | ||
context.extraArtifacts[`${filePath}.js`] = ` | ||
module.exports = link; | ||
`; | ||
log.info('css-loader', `Generated .js module to inject '${href}'`); | ||
} | ||
exports.default = default_1; | ||
function getHref(filePath, extension, pathModule) { | ||
var webContextPath = void 0; | ||
if (_project2.default.jar.supported) { | ||
webContextPath = _project2.default.jar.webContextPath; | ||
} else { | ||
var bnd = _fs2.default.readFileSync(_project2.default.dir.join('bnd.bnd').asNative).toString(); | ||
var lines = bnd.split('\n'); | ||
var webContextPathLine = lines.find(function (line) { | ||
return line.startsWith('Web-ContextPath:'); | ||
}); | ||
webContextPath = webContextPathLine.substring(16).trim(); | ||
} | ||
_project2.default.sources.asNative.forEach(function (sourcePath) { | ||
// Remove `./` from sourcePath so that it matches the filePath correctly | ||
sourcePath = sourcePath.substring(2); | ||
if (filePath.startsWith(sourcePath)) { | ||
filePath = filePath.substring(sourcePath.length + 1); | ||
} | ||
}); | ||
if (extension !== undefined) { | ||
var extname = _path2.default.extname(filePath); | ||
if (extname == '') { | ||
filePath = filePath + '.' + extension; | ||
} else { | ||
filePath = filePath.replace(new RegExp('\\' + extname + '$'), '' + extension); | ||
} | ||
} | ||
filePath = new _filePath2.default(filePath).asPosix; | ||
return '' + pathModule + webContextPath + '/' + filePath; | ||
let webContextPath; | ||
if (project_1.default.jar.supported) { | ||
webContextPath = project_1.default.jar.webContextPath; | ||
} | ||
else { | ||
const bnd = fs_1.default | ||
.readFileSync(project_1.default.dir.join('bnd.bnd').asNative) | ||
.toString(); | ||
const lines = bnd.split('\n'); | ||
const webContextPathLine = lines.find(line => line.startsWith('Web-ContextPath:')); | ||
webContextPath = webContextPathLine.substring(16).trim(); | ||
} | ||
project_1.default.sources | ||
.map(source => source.asNative) | ||
.forEach(sourcePath => { | ||
// Remove `./` from sourcePath so that it matches the filePath correctly | ||
sourcePath = sourcePath.substring(2); | ||
if (filePath.startsWith(sourcePath)) { | ||
filePath = filePath.substring(sourcePath.length + 1); | ||
} | ||
}); | ||
if (extension !== undefined) { | ||
const extname = path_1.default.extname(filePath); | ||
if (extname == '') { | ||
filePath = `${filePath}.${extension}`; | ||
} | ||
else { | ||
filePath = filePath.replace(new RegExp(`\\${extname}$`), `${extension}`); | ||
} | ||
} | ||
filePath = new file_path_1.default(filePath).asPosix; | ||
return `${pathModule}${webContextPath}/${filePath}`; | ||
} | ||
/** | ||
* @param {object} context loader's context | ||
*/ | ||
/** | ||
* © 2017 Liferay, Inc. <https://liferay.com> | ||
* | ||
* SPDX-License-Identifier: LGPL-3.0-or-later | ||
*/ | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "liferay-npm-bundler-loader-css-loader", | ||
"version": "2.13.2", | ||
"description": "A liferay-npm-bundler loader that turns CSS files into JavaScript modules that inject a <link> into the HTML when they are required.", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"build": "babel --source-maps -D -d lib src", | ||
"prepublish": "npm run build" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.24.1", | ||
"babel-preset-es2015": "^6.24.1" | ||
}, | ||
"dependencies": { | ||
"liferay-npm-build-tools-common": "2.13.2" | ||
} | ||
"name": "liferay-npm-bundler-loader-css-loader", | ||
"version": "2.13.3-alpha.6+ae09044", | ||
"description": "A liferay-npm-bundler loader that turns CSS files into JavaScript modules that inject a <link> into the HTML when they are required.", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"copyfiles": "node ../../scripts/copyfiles.js", | ||
"build": "tsc && yarn copyfiles", | ||
"prepublish": "yarn build" | ||
}, | ||
"dependencies": { | ||
"liferay-npm-build-tools-common": "2.13.3-alpha.6+ae09044" | ||
}, | ||
"gitHead": "ae09044beb216743cb2f1e2273aa6e055716ce64" | ||
} |
@@ -68,10 +68,12 @@ /** | ||
project.sources.asNative.forEach(sourcePath => { | ||
// Remove `./` from sourcePath so that it matches the filePath correctly | ||
sourcePath = sourcePath.substring(2); | ||
project.sources | ||
.map(source => source.asNative) | ||
.forEach(sourcePath => { | ||
// Remove `./` from sourcePath so that it matches the filePath correctly | ||
sourcePath = sourcePath.substring(2); | ||
if (filePath.startsWith(sourcePath)) { | ||
filePath = filePath.substring(sourcePath.length + 1); | ||
} | ||
}); | ||
if (filePath.startsWith(sourcePath)) { | ||
filePath = filePath.substring(sourcePath.length + 1); | ||
} | ||
}); | ||
@@ -78,0 +80,0 @@ if (extension !== undefined) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
0
20074
12
2
70
285
2
1
- Removed@mrmlnc/readdir-enhanced@2.2.1(transitive)
- Removed@nodelib/fs.stat@1.1.3(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.13.2.1(transitive)
- Removedarr-diff@4.0.0(transitive)
- Removedarr-flatten@1.1.0(transitive)
- Removedarr-union@3.1.0(transitive)
- Removedarray-union@1.0.2(transitive)
- Removedarray-uniq@1.0.3(transitive)
- Removedarray-unique@0.3.2(transitive)
- Removedarrify@1.0.1(transitive)
- Removedassign-symbols@1.0.0(transitive)
- Removedatob@2.1.2(transitive)
- Removedbabel-code-frame@6.26.0(transitive)
- Removedbabel-helper-evaluate-path@0.5.0(transitive)
- Removedbabel-helper-mark-eval-scopes@0.4.3(transitive)
- Removedbabel-helper-remove-or-void@0.4.3(transitive)
- Removedbabel-messages@6.23.0(transitive)
- Removedbabel-plugin-add-module-metadata@2.13.2(transitive)
- Removedbabel-plugin-minify-dead-code-elimination@0.5.0(transitive)
- Removedbabel-plugin-name-amd-modules@2.13.2(transitive)
- Removedbabel-plugin-namespace-amd-define@2.13.2(transitive)
- Removedbabel-plugin-namespace-modules@2.13.2(transitive)
- Removedbabel-plugin-normalize-requires@2.13.2(transitive)
- Removedbabel-plugin-transform-node-env-inline@0.2.0(transitive)
- Removedbabel-plugin-wrap-modules-amd@2.13.2(transitive)
- Removedbabel-preset-liferay-standard@2.13.2(transitive)
- Removedbabel-runtime@6.26.0(transitive)
- Removedbabel-template@6.26.0(transitive)
- Removedbabel-traverse@6.26.0(transitive)
- Removedbabel-types@6.26.0(transitive)
- Removedbabylon@6.18.0(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbase@0.11.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedbraces@2.3.2(transitive)
- Removedcache-base@1.0.1(transitive)
- Removedcall-me-maybe@1.0.2(transitive)
- Removedchalk@1.1.32.4.2(transitive)
- Removedclass-utils@0.3.6(transitive)
- Removedcollection-visit@1.0.0(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedcomponent-emitter@1.3.1(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedcopy-descriptor@0.1.1(transitive)
- Removedcore-js@2.6.12(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddecode-uri-component@0.2.2(transitive)
- Removeddefine-property@0.2.51.0.02.0.2(transitive)
- Removeddir-glob@2.0.0(transitive)
- Removeddot-prop@5.3.0(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedesutils@2.0.3(transitive)
- Removedexpand-brackets@2.1.4(transitive)
- Removedextend-shallow@2.0.13.0.2(transitive)
- Removedextglob@2.0.4(transitive)
- Removedfast-glob@2.2.7(transitive)
- Removedfill-range@4.0.0(transitive)
- Removedfor-in@1.0.2(transitive)
- Removedfragment-cache@0.2.1(transitive)
- Removedfs-extra@7.0.1(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-value@2.0.6(transitive)
- Removedglob@7.2.3(transitive)
- Removedglob-parent@3.1.0(transitive)
- Removedglob-to-regexp@0.3.0(transitive)
- Removedglobals@9.18.0(transitive)
- Removedglobby@8.0.2(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedhas-value@0.3.11.0.0(transitive)
- Removedhas-values@0.1.41.0.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedignore@3.3.10(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedinvariant@2.2.4(transitive)
- Removedis-accessor-descriptor@1.0.1(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedis-data-descriptor@1.0.1(transitive)
- Removedis-descriptor@0.1.71.0.3(transitive)
- Removedis-extendable@0.1.11.0.1(transitive)
- Removedis-extglob@2.1.1(transitive)
- Removedis-glob@3.1.04.0.3(transitive)
- Removedis-number@3.0.0(transitive)
- Removedis-obj@2.0.0(transitive)
- Removedis-plain-object@2.0.4(transitive)
- Removedis-windows@1.0.2(transitive)
- Removedisarray@1.0.0(transitive)
- Removedisobject@2.1.03.0.1(transitive)
- Removedjs-tokens@3.0.2(transitive)
- Removedjsonfile@4.0.0(transitive)
- Removedkind-of@3.2.24.0.06.0.3(transitive)
- Removedliferay-npm-build-tools-common@2.13.2(transitive)
- Removedliferay-npm-bundler-plugin-exclude-imports@2.13.2(transitive)
- Removedliferay-npm-bundler-plugin-inject-imports-dependencies@2.13.2(transitive)
- Removedliferay-npm-bundler-plugin-inject-peer-dependencies@2.13.2(transitive)
- Removedliferay-npm-bundler-plugin-namespace-packages@2.13.2(transitive)
- Removedliferay-npm-bundler-plugin-replace-browser-modules@2.13.2(transitive)
- Removedliferay-npm-bundler-plugin-resolve-linked-dependencies@2.13.2(transitive)
- Removedliferay-npm-bundler-preset-standard@2.13.2(transitive)
- Removedlodash@4.17.21(transitive)
- Removedlodash.some@4.6.0(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedmap-cache@0.2.2(transitive)
- Removedmap-visit@1.0.0(transitive)
- Removedmerge@1.2.1(transitive)
- Removedmerge2@1.4.1(transitive)
- Removedmicromatch@3.1.10(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedmixin-deep@1.3.2(transitive)
- Removedms@2.0.0(transitive)
- Removednanomatch@1.2.13(transitive)
- Removedobject-copy@0.1.0(transitive)
- Removedobject-visit@1.0.1(transitive)
- Removedobject.pick@1.3.0(transitive)
- Removedonce@1.4.0(transitive)
- Removedpascalcase@0.1.1(transitive)
- Removedpath-dirname@1.0.2(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpath-type@3.0.0(transitive)
- Removedpify@3.0.0(transitive)
- Removedposix-character-classes@0.1.1(transitive)
- Removedproperties@1.2.1(transitive)
- Removedread-json-sync@1.1.12.0.1(transitive)
- Removedregenerator-runtime@0.11.1(transitive)
- Removedregex-not@1.0.2(transitive)
- Removedrepeat-element@1.1.4(transitive)
- Removedrepeat-string@1.6.1(transitive)
- Removedresolve@1.22.8(transitive)
- Removedresolve-url@0.2.1(transitive)
- Removedret@0.1.15(transitive)
- Removedsafe-regex@1.1.0(transitive)
- Removedsemver@5.7.2(transitive)
- Removedset-value@2.0.1(transitive)
- Removedslash@1.0.0(transitive)
- Removedsnapdragon@0.8.2(transitive)
- Removedsnapdragon-node@2.1.1(transitive)
- Removedsnapdragon-util@3.0.1(transitive)
- Removedsource-map@0.5.7(transitive)
- Removedsource-map-resolve@0.5.3(transitive)
- Removedsource-map-url@0.4.1(transitive)
- Removedsplit-string@3.1.0(transitive)
- Removedstatic-extend@0.1.2(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.05.5.0(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedto-fast-properties@1.0.3(transitive)
- Removedto-object-path@0.3.0(transitive)
- Removedto-regex@3.0.2(transitive)
- Removedto-regex-range@2.1.1(transitive)
- Removedunion-value@1.0.1(transitive)
- Removeduniversalify@0.1.2(transitive)
- Removedunset-value@1.0.0(transitive)
- Removedurix@0.1.0(transitive)
- Removeduse@3.1.1(transitive)
- Removedwrappy@1.0.2(transitive)
Updatedliferay-npm-build-tools-common@2.13.3-alpha.6+ae09044