From 675418278eab302a36c95c65a6d63f02167d3a41 Mon Sep 17 00:00:00 2001 From: Dmytro Dzyuba Date: Mon, 21 Mar 2022 11:15:10 +0200 Subject: [PATCH 1/2] Fix for polymer2 + webpack 5 Dmytro Dzyuba --- .gitignore | 1 - dist/cjs.js | 3 + dist/index.js | 653 + package-lock.json | 34838 +++++++++++++++++++++++++++++--------------- package.json | 10 +- src/index.js | 35 +- 6 files changed, 23727 insertions(+), 11813 deletions(-) create mode 100644 dist/cjs.js create mode 100644 dist/index.js diff --git a/.gitignore b/.gitignore index 82bc7a2..87adec2 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ logs npm-debug.log* .eslintcache /coverage -/dist /local /reports /node_modules diff --git a/dist/cjs.js b/dist/cjs.js new file mode 100644 index 0000000..c893ee9 --- /dev/null +++ b/dist/cjs.js @@ -0,0 +1,3 @@ +"use strict"; + +module.exports = require('./index').default; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..33f6ea3 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,653 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = entry; + +var _url = _interopRequireDefault(require("url")); + +var _dom = require("dom5"); + +var _loaderUtils = _interopRequireDefault(require("loader-utils")); + +var _parse = _interopRequireDefault(require("parse5")); + +var _espree = _interopRequireDefault(require("espree")); + +var _sourceMap = _interopRequireDefault(require("source-map")); + +var _htmlLoader2 = _interopRequireDefault(require("html-loader")); + +var _cssSelectorTokenizer = _interopRequireDefault(require("css-selector-tokenizer")); + +var _postcss = _interopRequireDefault(require("postcss")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } + +/** @enum {number} */ +var RuntimeRegistrationType = { + DOM_MODULE: 0, + BODY: 1 +}; +var htmlLoaderDefaultOptions = { + minimize: true, + cacheable: false, + minifyCSS: { + inline: ['none'] + } +}; +var STYLE_ID_PREFIX = '__POLYMER_WEBPACK_LOADER_STYLE_'; +var STYLE_ID_EXPR = new RegExp(`/\\* (${STYLE_ID_PREFIX}\\d+__) \\*/`, 'g'); +var STYLE_URL_PREFIX = '__POLYMER_WEBPACK_LOADER_URL_'; +var STYLE_URL_EXPR = new RegExp(`${STYLE_URL_PREFIX}\\d+__`, 'g'); +var STYLE_URL_IMPORT_EXPR = new RegExp(``, 'g'); +/* eslint class-methods-use-this: ["error", { "exceptMethods": ["scripts"] }] */ + +var ProcessHtml = /*#__PURE__*/function () { + function ProcessHtml(content, loader) { + _classCallCheck(this, ProcessHtml); + + this.content = content; + this.options = _loaderUtils.default.getOptions(loader) || {}; + this.currentFilePath = loader.resourcePath; + this.loader = loader; + this.currentStyleId_ = 0; + this.stylePlaceholders = new Map(); + } + /** + * Process `` tags, `` elements, and any `