@enhanced-dom/webpack 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler.helpers.d.ts +1 -1
- package/compiler.helpers.js +4 -3
- package/compiler.helpers.js.map +1 -1
- package/configs/index.d.ts +6 -3
- package/configs/index.js +9 -7
- package/configs/index.js.map +1 -1
- package/index.js +17 -7
- package/index.js.map +1 -1
- package/loaders/WebcomponentStyleLoader.d.ts +5 -0
- package/loaders/WebcomponentStyleLoader.js +70 -0
- package/loaders/WebcomponentStyleLoader.js.map +1 -0
- package/loaders/index.js +37 -27
- package/loaders/index.js.map +1 -1
- package/package.json +25 -27
- package/loaders/ExposeCssSourceLoader.d.ts +0 -5
- package/loaders/ExposeCssSourceLoader.js +0 -27
- package/loaders/ExposeCssSourceLoader.js.map +0 -1
package/compiler.helpers.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Compiler, type Configuration } from 'webpack';
|
|
2
2
|
import MemoryFS from 'memory-fs';
|
|
3
|
-
export declare const proxyFilesystem: (originalFilesystem: Compiler[
|
|
3
|
+
export declare const proxyFilesystem: (originalFilesystem: Compiler["inputFileSystem"]) => MemoryFS;
|
|
4
4
|
export declare const patchCompilerFileSystem: (originalCompiler: Compiler, allowProxy?: boolean) => Omit<Compiler, "inputFileSystem" | "outputFileSystem"> & {
|
|
5
5
|
inputFileSystem: MemoryFS;
|
|
6
6
|
outputFileSystem: MemoryFS;
|
package/compiler.helpers.js
CHANGED
|
@@ -31,9 +31,10 @@ const proxyFilesystem = (originalFilesystem) => {
|
|
|
31
31
|
};
|
|
32
32
|
exports.proxyFilesystem = proxyFilesystem;
|
|
33
33
|
const patchCompilerFileSystem = (originalCompiler, allowProxy = true) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
const transformedCompiler = originalCompiler;
|
|
35
|
+
transformedCompiler.inputFileSystem = allowProxy ? (0, exports.proxyFilesystem)(originalCompiler.inputFileSystem) : new memory_fs_1.default();
|
|
36
|
+
transformedCompiler.outputFileSystem = new memory_fs_1.default();
|
|
37
|
+
return transformedCompiler;
|
|
37
38
|
};
|
|
38
39
|
exports.patchCompilerFileSystem = patchCompilerFileSystem;
|
|
39
40
|
const getInMemoryCompiler = (webpackConfig, allowProxy = true) => {
|
package/compiler.helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.helpers.js","sourceRoot":"./","sources":["compiler.helpers.ts"],"names":[],"mappings":";;;;;;AAAA,qCAAoE;AACpE,0DAAgC;AAEzB,MAAM,eAAe,GAAG,CAAC,kBAA+C,EAAE,EAAE;IACjF,8HAA8H;IAC9H,MAAM,KAAK,GAAG,IAAI,mBAAQ,EAAE,CAAA;IAC5B,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACvC,MAAM,YAAY,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC/C,KAAK,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE;QAC5B,QAAQ,CAAC,QAAQ,EAAE,CAAC,GAAU,EAAE,MAAW,EAAE,EAAE;YAC7C,IAAI,GAAG,EAAE,CAAC;gBACR,OAAO,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;YAC9C,CAAC;YACD,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACxB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;IACD,KAAK,CAAC,QAAQ,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE;QAChC,YAAY,CAAC,QAAQ,EAAE,CAAC,GAAU,EAAE,MAAW,EAAE,EAAE;YACjD,IAAI,GAAG,EAAE,CAAC;gBACR,OAAO,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE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EAAE,CAAC,CAAA;YAClD,CAAC;YACD,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACxB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAvBY,QAAA,eAAe,mBAuB3B;AAEM,MAAM,uBAAuB,GAAG,CAAC,gBAA0B,EAAE,UAAU,GAAG,IAAI,EAAE,EAAE;IACvF,MAAM,mBAAmB,GAAG,gBAG3B,CAAA;IACD,mBAAmB,CAAC,eAAe,GAAG,UAAU,CAAC,CAAC,CAAC,IAAA,uBAAe,EAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,mBAAQ,EAAE,CAAA;IACrH,mBAAmB,CAAC,gBAAgB,GAAG,IAAI,mBAAQ,EAAE,CAAA;IAErD,OAAO,mBAAmB,CAAA;AAC5B,CAAC,CAAA;AATY,QAAA,uBAAuB,2BASnC;AAEM,MAAM,mBAAmB,GAAG,CAAC,aAA4B,EAAE,UAAU,GAAG,IAAI,EAAE,EAAE;IACrF,OAAO,IAAA,+BAAuB,EAAC,IAAA,iBAAO,EAAC,aAAa,CAAC,EAAE,UAAU,CAAC,CAAA;AACpE,CAAC,CAAA;AAFY,QAAA,mBAAmB,uBAE/B","sourcesContent":["import { type Compiler, type Configuration, webpack } from 'webpack'\nimport MemoryFS from 'memory-fs'\n\nexport const proxyFilesystem = (originalFilesystem: Compiler['inputFileSystem']) => {\n // Inspired by: https://stackoverflow.com/questions/38779924/compiling-webpack-in-memory-but-resolving-to-node-modules-on-disk\n const memFs = new MemoryFS()\n const statOrig = memFs.stat.bind(memFs)\n const readFileOrig = memFs.readFile.bind(memFs)\n memFs.stat = (filePath, cb) => {\n statOrig(filePath, (err: Error, result: any) => {\n if (err) {\n return originalFilesystem.stat(filePath, cb)\n }\n return cb(err, result)\n })\n }\n memFs.readFile = (filePath, cb) => {\n readFileOrig(filePath, (err: Error, result: any) => {\n if (err) {\n return originalFilesystem.readFile(filePath, cb)\n }\n return cb(err, result)\n })\n }\n\n return memFs\n}\n\nexport const patchCompilerFileSystem = (originalCompiler: Compiler, allowProxy = true) => {\n const transformedCompiler = originalCompiler as unknown as Omit<Compiler, 'inputFileSystem' | 'outputFileSystem'> & {\n inputFileSystem: MemoryFS\n outputFileSystem: MemoryFS\n }\n transformedCompiler.inputFileSystem = allowProxy ? proxyFilesystem(originalCompiler.inputFileSystem) : new MemoryFS()\n transformedCompiler.outputFileSystem = new MemoryFS()\n\n return transformedCompiler\n}\n\nexport const getInMemoryCompiler = (webpackConfig: Configuration, allowProxy = true) => {\n return patchCompilerFileSystem(webpack(webpackConfig), allowProxy)\n}\n"]}
|
package/configs/index.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import IgnoreEmitWebpackPlugin from 'ignore-emit-webpack-plugin';
|
|
2
|
-
export declare const typedStylesConfigFactory: ({ raw,
|
|
2
|
+
export declare const typedStylesConfigFactory: ({ raw, filePaths, outputPath }: {
|
|
3
3
|
raw?: boolean;
|
|
4
|
-
|
|
4
|
+
filePaths: string[];
|
|
5
|
+
outputPath?: string;
|
|
5
6
|
}) => {
|
|
6
7
|
mode: string;
|
|
7
8
|
entry: {
|
|
8
9
|
bundle: string[];
|
|
9
10
|
};
|
|
10
11
|
devtool: boolean;
|
|
11
|
-
|
|
12
|
+
output: {
|
|
13
|
+
path: string;
|
|
14
|
+
};
|
|
12
15
|
module: {
|
|
13
16
|
rules: {
|
|
14
17
|
test: RegExp;
|
package/configs/index.js
CHANGED
|
@@ -5,26 +5,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.typedStylesConfigFactory = void 0;
|
|
7
7
|
const ignore_emit_webpack_plugin_1 = __importDefault(require("ignore-emit-webpack-plugin"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
8
9
|
const loaders_1 = require("../loaders");
|
|
9
|
-
const typedStylesConfigFactory = ({ raw,
|
|
10
|
+
const typedStylesConfigFactory = ({ raw, filePaths, outputPath }) => {
|
|
11
|
+
const fileRegexes = filePaths.map((filePath) => new RegExp(`^((?!${path_1.default.basename(filePath).replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')}).)*$`));
|
|
10
12
|
return {
|
|
11
|
-
mode: '
|
|
12
|
-
entry: { bundle:
|
|
13
|
+
mode: 'development',
|
|
14
|
+
entry: { bundle: filePaths },
|
|
13
15
|
devtool: false,
|
|
14
|
-
|
|
16
|
+
output: outputPath ? { path: outputPath } : undefined,
|
|
15
17
|
module: {
|
|
16
18
|
rules: [
|
|
17
19
|
{
|
|
18
20
|
test: /\.(pcss|css)$/,
|
|
19
|
-
use: (0, loaders_1.styleConfigFactory)({ raw, typedStyles: true, parser: 'postcss',
|
|
21
|
+
use: (0, loaders_1.styleConfigFactory)({ raw, typedStyles: true, parser: 'postcss', extract: !!outputPath }),
|
|
20
22
|
},
|
|
21
23
|
{
|
|
22
24
|
test: /\.(scss|sass)$/,
|
|
23
|
-
use: (0, loaders_1.styleConfigFactory)({ raw, typedStyles: true, parser: 'postcss-scss',
|
|
25
|
+
use: (0, loaders_1.styleConfigFactory)({ raw, typedStyles: true, parser: 'postcss-scss', extract: !!outputPath }),
|
|
24
26
|
},
|
|
25
27
|
],
|
|
26
28
|
},
|
|
27
|
-
plugins: [new ignore_emit_webpack_plugin_1.default(
|
|
29
|
+
plugins: [new ignore_emit_webpack_plugin_1.default(fileRegexes)],
|
|
28
30
|
};
|
|
29
31
|
};
|
|
30
32
|
exports.typedStylesConfigFactory = typedStylesConfigFactory;
|
package/configs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"./","sources":["configs/index.ts"],"names":[],"mappings":";;;;;;AAAA,4FAAgE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"./","sources":["configs/index.ts"],"names":[],"mappings":";;;;;;AAAA,4FAAgE;AAChE,gDAAuB;AAEvB,wCAA+C;AAExC,MAAM,wBAAwB,GAAG,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAA+D,EAAE,EAAE;IACtI,MAAM,WAAW,GAAG,SAAS,CAAC,GAAG,CAC/B,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,QAAQ,cAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,0BAA0B,EAAE,MAAM,CAAC,OAAO,CAAC,CAC7G,CAAA;IACD,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;QAC5B,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS;QACrD,MAAM,EAAE;YACN,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,eAAe;oBACrB,GAAG,EAAE,IAAA,4BAAkB,EAAC,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC;iBAC9F;gBACD;oBACE,IAAI,EAAE,gBAAgB;oBACtB,GAAG,EAAE,IAAA,4BAAkB,EAAC,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC;iBACnG;aACF;SACF;QACD,OAAO,EAAE,CAAC,IAAI,oCAAuB,CAAC,WAAW,CAAC,CAAC;KACpD,CAAA;AACH,CAAC,CAAA;AAvBY,QAAA,wBAAwB,4BAuBpC","sourcesContent":["import IgnoreEmitWebpackPlugin from 'ignore-emit-webpack-plugin'\nimport path from 'path'\n\nimport { styleConfigFactory } from '../loaders'\n\nexport const typedStylesConfigFactory = ({ raw, filePaths, outputPath }: { raw?: boolean; filePaths: string[]; outputPath?: string }) => {\n const fileRegexes = filePaths.map(\n (filePath) => new RegExp(`^((?!${path.basename(filePath).replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&')}).)*$`),\n )\n return {\n mode: 'development',\n entry: { bundle: filePaths },\n devtool: false,\n output: outputPath ? { path: outputPath } : undefined,\n module: {\n rules: [\n {\n test: /\\.(pcss|css)$/,\n use: styleConfigFactory({ raw, typedStyles: true, parser: 'postcss', extract: !!outputPath }),\n },\n {\n test: /\\.(scss|sass)$/,\n use: styleConfigFactory({ raw, typedStyles: true, parser: 'postcss-scss', extract: !!outputPath }),\n },\n ],\n },\n plugins: [new IgnoreEmitWebpackPlugin(fileRegexes)],\n }\n}\n"]}
|
package/index.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
const loaders = __importStar(require("./loaders"));
|
|
26
36
|
const plugins = __importStar(require("./plugins"));
|
|
27
37
|
const configs = __importStar(require("./configs"));
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"./","sources":["index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"./","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAoC;AACpC,mDAAoC;AACpC,mDAAoC;AACpC,6DAA8C;AAC9C,iBAAS;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,QAAQ;CACT,CAAA","sourcesContent":["import * as loaders from './loaders'\nimport * as plugins from './plugins'\nimport * as configs from './configs'\nimport * as compiler from './compiler.helpers'\nexport = {\n loaders,\n plugins,\n configs,\n compiler,\n}\n"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const path_1 = __importDefault(require("path"));
|
|
6
|
+
const fs_1 = __importDefault(require("fs"));
|
|
7
|
+
const schema_utils_1 = require("schema-utils");
|
|
8
|
+
const schema = {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
pathPrefix: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
},
|
|
14
|
+
emit: {
|
|
15
|
+
type: 'boolean',
|
|
16
|
+
},
|
|
17
|
+
typings: {
|
|
18
|
+
type: 'boolean',
|
|
19
|
+
},
|
|
20
|
+
raw: {
|
|
21
|
+
type: 'boolean',
|
|
22
|
+
},
|
|
23
|
+
named: {
|
|
24
|
+
type: 'boolean',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
additionalProperties: false,
|
|
28
|
+
};
|
|
29
|
+
const loader = function (content) {
|
|
30
|
+
var _a;
|
|
31
|
+
const options = this.getOptions();
|
|
32
|
+
(0, schema_utils_1.validate)(schema, options, { name: 'webcomponent-styles' });
|
|
33
|
+
if (options.emit) {
|
|
34
|
+
const pathPrefix = (_a = options.pathPrefix) !== null && _a !== void 0 ? _a : path_1.default.join(process.cwd(), 'src');
|
|
35
|
+
const transformedAssetPath = path_1.default
|
|
36
|
+
.join(path_1.default.dirname(this.resourcePath), `${path_1.default.basename(this.resourcePath)}.js`)
|
|
37
|
+
.replace(pathPrefix, '');
|
|
38
|
+
const transformedCode = Object.entries(this.data)
|
|
39
|
+
.map(([exportName, exportValue]) => `export const ${exportName} = ${exportValue}`)
|
|
40
|
+
.join('\n');
|
|
41
|
+
this.emitFile(transformedAssetPath, transformedCode);
|
|
42
|
+
if (options.typings) {
|
|
43
|
+
const transformedDtsPath = path_1.default
|
|
44
|
+
.join(path_1.default.dirname(this.resourcePath), `${path_1.default.basename(this.resourcePath)}.d.ts`)
|
|
45
|
+
.replace(pathPrefix, '');
|
|
46
|
+
const typingsCode = [...Object.keys(this.data).map((exportName) => `export const ${exportName}: string;`)].join('\n');
|
|
47
|
+
this.emitFile(transformedDtsPath, typingsCode);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (options.typings) {
|
|
51
|
+
const dtsPath = path_1.default.join(path_1.default.dirname(this.resourcePath), `${path_1.default.basename(this.resourcePath)}.d.ts`);
|
|
52
|
+
const typingsCode = [...Object.keys(this.data).map((exportName) => `export const ${exportName}: string;`)].join('\n');
|
|
53
|
+
if (!fs_1.default.existsSync(dtsPath) || fs_1.default.readFileSync(dtsPath, 'utf-8') != typingsCode) {
|
|
54
|
+
fs_1.default.writeFileSync(dtsPath, typingsCode, 'utf8');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return options.raw ? content + `export var css = ${this.data.css};\n` : content;
|
|
58
|
+
};
|
|
59
|
+
loader.pitch = async function (request) {
|
|
60
|
+
const options = this.getOptions();
|
|
61
|
+
(0, schema_utils_1.validate)(schema, options, { name: 'webcomponent-styles' });
|
|
62
|
+
const result = await this.importModule(this.resourcePath + '.webpack[javascript/auto]' + '!=!' + request);
|
|
63
|
+
const { default: defaultExport, ...otherExports } = result;
|
|
64
|
+
if (options.raw) {
|
|
65
|
+
this.data.css = `\`${defaultExport.toString()}\``;
|
|
66
|
+
}
|
|
67
|
+
Object.entries(otherExports).forEach(([exportName, exportValue]) => (this.data[exportName] = `'${exportValue.replace(/^["|'](.+)["|']$/, '$1')}'`));
|
|
68
|
+
};
|
|
69
|
+
module.exports = loader;
|
|
70
|
+
//# sourceMappingURL=WebcomponentStyleLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebcomponentStyleLoader.js","sourceRoot":"./","sources":["loaders/WebcomponentStyleLoader.ts"],"names":[],"mappings":";;;;AAAA,gDAAuB;AACvB,4CAAmB;AACnB,+CAAuC;AAGvC,MAAM,MAAM,GAAgB;IAC1B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;SACf;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,SAAS;SAChB;QACD,OAAO,EAAE;YACP,IAAI,EAAE,SAAS;SAChB;QACD,GAAG,EAAE;YACH,IAAI,EAAE,SAAS;SAChB;QACD,KAAK,EAAE;YACL,IAAI,EAAE,SAAS;SAChB;KACF;IACD,oBAAoB,EAAE,KAAK;CAC5B,CAAA;AAED,MAAM,MAAM,GAAG,UAAU,OAAe;;IACtC,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAA;IACjC,IAAA,uBAAQ,EAAC,MAAM,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC,CAAA;IAE1D,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,MAAM,UAAU,GAAG,MAAA,OAAO,CAAC,UAAU,mCAAI,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,E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AAC,CAAC,OAAO,CAClC,CAAC,CAAC,UAAU,EAAE,WAAW,CAAmB,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,kBAAkB,EAAE,IAAI,CAAC,GAAG,CAAC,CAChI,CAAA;AACH,CAAC,CAAA;AAED,iBAAS,MAAM,CAAA","sourcesContent":["import path from 'path'\nimport fs from 'fs'\nimport { validate } from 'schema-utils'\nimport { type JSONSchema7 } from 'json-schema' // eslint-disable-line import/no-unresolved\n\nconst schema: JSONSchema7 = {\n type: 'object',\n properties: {\n pathPrefix: {\n type: 'string',\n },\n emit: {\n type: 'boolean',\n },\n typings: {\n type: 'boolean',\n },\n raw: {\n type: 'boolean',\n },\n named: {\n type: 'boolean',\n },\n },\n additionalProperties: false,\n}\n\nconst loader = function (content: string) {\n const options = this.getOptions()\n validate(schema, options, { name: 'webcomponent-styles' })\n\n if (options.emit) {\n const pathPrefix = options.pathPrefix ?? path.join(process.cwd(), 'src')\n const transformedAssetPath = path\n .join(path.dirname(this.resourcePath), `${path.basename(this.resourcePath)}.js`)\n .replace(pathPrefix, '')\n const transformedCode = Object.entries(this.data)\n .map(([exportName, exportValue]: [string, string]) => `export const ${exportName} = ${exportValue}`)\n .join('\\n')\n this.emitFile(transformedAssetPath, transformedCode)\n if (options.typings) {\n const transformedDtsPath = path\n .join(path.dirname(this.resourcePath), `${path.basename(this.resourcePath)}.d.ts`)\n .replace(pathPrefix, '')\n const typingsCode = [...Object.keys(this.data).map((exportName) => `export const ${exportName}: string;`)].join('\\n')\n this.emitFile(transformedDtsPath, typingsCode)\n }\n }\n if (options.typings) {\n const dtsPath = path.join(path.dirname(this.resourcePath), `${path.basename(this.resourcePath)}.d.ts`)\n const typingsCode = [...Object.keys(this.data).map((exportName) => `export const ${exportName}: string;`)].join('\\n')\n if (!fs.existsSync(dtsPath) || fs.readFileSync(dtsPath, 'utf-8') != typingsCode) {\n fs.writeFileSync(dtsPath, typingsCode, 'utf8')\n }\n }\n\n return options.raw ? content + `export var css = ${this.data.css};\\n` : content\n}\n\nloader.pitch = async function (request: string) {\n const options = this.getOptions()\n validate(schema, options, { name: 'webcomponent-styles' })\n const result = await this.importModule(this.resourcePath + '.webpack[javascript/auto]' + '!=!' + request)\n const { default: defaultExport, ...otherExports } = result\n if (options.raw) {\n this.data.css = `\\`${defaultExport.toString()}\\``\n }\n Object.entries(otherExports).forEach(\n ([exportName, exportValue]: [string, string]) => (this.data[exportName] = `'${exportValue.replace(/^[\"|'](.+)[\"|']$/, '$1')}'`),\n )\n}\n\nexport = loader\n"]}
|
package/loaders/index.js
CHANGED
|
@@ -6,40 +6,45 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.markdownConfigFactory = exports.babelConfigFactory = exports.assetExtensions = exports.imageExtensions = exports.fontExtensions = exports.nullConfigFactory = exports.styleConfigFactory = void 0;
|
|
7
7
|
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
8
8
|
const postcss_import_webpack_resolver_1 = __importDefault(require("postcss-import-webpack-resolver"));
|
|
9
|
-
const
|
|
9
|
+
const WebcomponentStyleLoader = require.resolve('./WebcomponentStyleLoader');
|
|
10
10
|
const remark_code_import_1 = __importDefault(require("remark-code-import"));
|
|
11
|
-
const
|
|
11
|
+
const rehype_unwrap_images_1 = __importDefault(require("rehype-unwrap-images"));
|
|
12
12
|
const remark_embed_images_1 = __importDefault(require("remark-embed-images"));
|
|
13
13
|
const styleConfigFactory = ({ raw = false, extract = false, sourceMap = false, typedStyles = false, modules = undefined, parser = undefined, aliases = {}, } = {}) => {
|
|
14
14
|
var _a;
|
|
15
15
|
const loaders = [];
|
|
16
16
|
if (raw) {
|
|
17
17
|
loaders.push({
|
|
18
|
-
loader:
|
|
18
|
+
loader: WebcomponentStyleLoader,
|
|
19
19
|
options: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
else if (extract) {
|
|
25
|
-
loaders.push({
|
|
26
|
-
loader: mini_css_extract_plugin_1.default.loader,
|
|
27
|
-
options: {
|
|
28
|
-
publicPath: './',
|
|
20
|
+
raw: true,
|
|
21
|
+
emit: extract,
|
|
22
|
+
typings: typedStyles,
|
|
29
23
|
},
|
|
30
24
|
});
|
|
31
25
|
}
|
|
32
26
|
else {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
27
|
+
if (extract) {
|
|
28
|
+
loaders.push({
|
|
29
|
+
loader: mini_css_extract_plugin_1.default.loader,
|
|
30
|
+
options: {
|
|
31
|
+
publicPath: './',
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
loaders.push({ loader: 'style-loader' });
|
|
37
|
+
}
|
|
38
|
+
if (typedStyles) {
|
|
39
|
+
loaders.push({
|
|
40
|
+
loader: WebcomponentStyleLoader,
|
|
41
|
+
options: {
|
|
42
|
+
raw: false,
|
|
43
|
+
emit: false,
|
|
44
|
+
typings: true,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
|
43
48
|
}
|
|
44
49
|
const cssLoader = {
|
|
45
50
|
loader: 'css-loader',
|
|
@@ -80,6 +85,8 @@ const styleConfigFactory = ({ raw = false, extract = false, sourceMap = false, t
|
|
|
80
85
|
postcssOptions: {
|
|
81
86
|
parser,
|
|
82
87
|
plugins: [
|
|
88
|
+
'postcss-normalize-whitespace',
|
|
89
|
+
'postcss-discard-comments',
|
|
83
90
|
[
|
|
84
91
|
'postcss-import',
|
|
85
92
|
{
|
|
@@ -90,10 +97,13 @@ const styleConfigFactory = ({ raw = false, extract = false, sourceMap = false, t
|
|
|
90
97
|
},
|
|
91
98
|
],
|
|
92
99
|
'postcss-nested',
|
|
93
|
-
'autoprefixer',
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
100
|
+
// 'autoprefixer',
|
|
101
|
+
[
|
|
102
|
+
'postcss-preset-env',
|
|
103
|
+
{
|
|
104
|
+
stage: 3,
|
|
105
|
+
},
|
|
106
|
+
],
|
|
97
107
|
],
|
|
98
108
|
},
|
|
99
109
|
},
|
|
@@ -126,7 +136,7 @@ const markdownConfigFactory = ({ babel, remark = [], rehype = [], useProvider =
|
|
|
126
136
|
loaders.push({
|
|
127
137
|
loader: '@mdx-js/loader',
|
|
128
138
|
options: {
|
|
129
|
-
remarkPlugins: [remark_code_import_1.default, remark_embed_images_1.default,
|
|
139
|
+
remarkPlugins: [remark_code_import_1.default, remark_embed_images_1.default, rehype_unwrap_images_1.default, ...remark],
|
|
130
140
|
rehypePlugins: rehype,
|
|
131
141
|
providerImportSource: useProvider ? '@mdx-js/react' : undefined,
|
|
132
142
|
},
|
package/loaders/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"./","sources":["loaders/index.ts"],"names":[],"mappings":";;;;;;AAAA,sFAA0D;AAC1D,sGAA4D;AAC5D,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"./","sources":["loaders/index.ts"],"names":[],"mappings":";;;;;;AAAA,sFAA0D;AAC1D,sGAA4D;AAC5D,MAAM,uBAAuB,GAAG,OAAO,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAA;AAC5E,4EAA2C;AAC3C,gFAA8C;AAC9C,8EAA6C;AAEtC,MAAM,kBAAkB,GAAG,CAAC,EACjC,GAAG,GAAG,KAAK,EACX,OAAO,GAAG,KAAK,EACf,SAAS,GAAG,KAAK,EACjB,WAAW,GAAG,KAAK,EACnB,OAAO,GAAG,SAEkD,EAC5D,MAAM,GAAG,SAAuC,EAChD,OAAO,GAAG,EAA4B,MACpC,EAAE,EAAE,EAAE;;IACR,MAAM,OAAO,GAAG,EAAE,CAAA;IAElB,IAAI,GAAG,EAAE,CAAC;QAC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,6BAAW,EAAE,8BAAW,EAAE,GAAG,MAAM,CAAC;gBAChE,aAAa,EAAE,MAAM;gBACrB,oBAAoB,EAAE,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS;aAChE;SACF,CAAC,CAAA;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,IAAI,CACV;YACE,MAAM,EAAE,aAAa;SACtB,EACD;YACE,MAAM,EAAE,iBAAiB;SAC1B,CACF,CAAA;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AA7BY,QAAA,qBAAqB,yBA6BjC","sourcesContent":["import MiniCssExtractPlugin from 'mini-css-extract-plugin'\nimport createResolver from 'postcss-import-webpack-resolver'\nconst WebcomponentStyleLoader = require.resolve('./WebcomponentStyleLoader')\nimport codeImport from 'remark-code-import'\nimport imageUnwrap from 'rehype-unwrap-images'\nimport imageImport from 'remark-embed-images'\n\nexport const styleConfigFactory = ({\n raw = false,\n extract = false,\n sourceMap = false,\n typedStyles = false,\n modules = undefined as\n | { localIdentName?: string; mappings?: { filter: string; transform: (p: string) => string }[] }\n | (boolean & { localIdentName?: never; mappings?: never }),\n parser = undefined as 'postcss' | 'postcss-scss',\n aliases = {} as Record<string, string>,\n} = {}) => {\n const loaders = []\n\n if (raw) {\n loaders.push({\n loader: WebcomponentStyleLoader,\n options: {\n raw: true,\n emit: extract,\n typings: typedStyles,\n },\n })\n } else {\n if (extract) {\n loaders.push({\n loader: MiniCssExtractPlugin.loader,\n options: {\n publicPath: './',\n },\n })\n } else {\n loaders.push({ loader: 'style-loader' })\n }\n\n if (typedStyles) {\n loaders.push({\n loader: WebcomponentStyleLoader,\n options: {\n raw: false,\n emit: false,\n typings: true,\n },\n })\n }\n }\n\n const cssLoader = {\n loader: 'css-loader',\n options: {\n sourceMap,\n ...(modules || typedStyles\n ? {\n esModule: true,\n modules: {\n localIdentName: modules?.localIdentName ?? '[local]_[hash:base64:5]',\n getLocalIdent: (loaderContext: { resourcePath: string }, _: any, localName: string) => {\n const { resourcePath } = loaderContext\n const mappings = modules?.mappings ?? []\n const mapping = mappings.find(({ filter }) => resourcePath.includes(filter))\n if (!mapping) {\n return undefined // this will trigger the default css-loader getLocalIdent function\n }\n return mapping.transform(localName)\n },\n exportLocalsConvention: 'camelCaseOnly',\n namedExport: true,\n },\n sourceMap,\n }\n : { modules: false }),\n },\n }\n\n loaders.push(cssLoader)\n\n const resolveUrlLoader = {\n loader: 'resolve-url-loader',\n }\n\n loaders.push(resolveUrlLoader)\n\n const postcssLoader = {\n loader: 'postcss-loader',\n options: {\n sourceMap: true,\n postcssOptions: {\n parser,\n plugins: [\n 'postcss-normalize-whitespace',\n 'postcss-discard-comments',\n [\n 'postcss-import',\n {\n resolve: createResolver({\n alias: aliases,\n }),\n modules: ['./node_modules', 'node_modules'],\n },\n ],\n 'postcss-nested',\n // 'autoprefixer',\n [\n 'postcss-preset-env',\n {\n stage: 3,\n },\n ],\n ],\n },\n },\n }\n\n loaders.push(postcssLoader)\n\n return loaders\n}\n\nexport const nullConfigFactory = ({ rules = [] as RegExp[] } = {}) => {\n return rules.map((rule) => ({\n test: rule,\n use: 'null-loader',\n enforce: 'post',\n }))\n}\n\nexport const fontExtensions = ['ttf', 'eot', 'woff', 'woff2']\nexport const imageExtensions = ['png', 'jpg', 'jpeg', 'gif', 'svg', 'ico']\nexport const assetExtensions = (extensions = [...imageExtensions, ...fontExtensions] as string[]) =>\n new RegExp(`\\\\.(${extensions.join('|')})(\\\\?.*$|$)?$`)\n\nexport const babelConfigFactory = ({ babel = undefined as any }) => {\n const loaders = [{ loader: 'babel-loader', options: babel }]\n return loaders\n}\n\nexport const markdownConfigFactory = ({\n babel,\n remark = [],\n rehype = [],\n useProvider = false,\n}: { babel?: any; remark?: any[]; rehype?: any[]; useProvider?: boolean } = {}) => {\n const loaders = []\n\n if (babel) {\n loaders.push(...babelConfigFactory({ babel }))\n loaders.push({\n loader: '@mdx-js/loader',\n options: {\n remarkPlugins: [codeImport, imageImport, imageUnwrap, ...remark],\n rehypePlugins: rehype,\n providerImportSource: useProvider ? '@mdx-js/react' : undefined,\n },\n })\n } else {\n loaders.push(\n {\n loader: 'html-loader',\n },\n {\n loader: 'markdown-loader',\n },\n )\n }\n return loaders\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enhanced-dom/webpack",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Helpers for webpack configuration",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"repository": "https://github.com/enhanced-dom/webpack.git",
|
|
@@ -8,14 +8,11 @@
|
|
|
8
8
|
"author": "CD9B4A105290E17E0948E021DF4105107C88693C59C0B891CCC08366C51AEA990902A6A156AC87D88A2FC41422A5E1C3C4071F251F19441C4516000EC25F87DF",
|
|
9
9
|
"main": "index.js",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@enhanced-dom/build": "
|
|
12
|
-
"@
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"css-loader": "^6.10.0",
|
|
17
|
-
"cssnano-preset-advanced": "^6.0.3",
|
|
18
|
-
"dts-css-modules-loader": "^2.0.1",
|
|
11
|
+
"@enhanced-dom/build": "~0.2.0",
|
|
12
|
+
"@mdx-js/loader": "^3.1.1",
|
|
13
|
+
"babel-loader": "^10.0.0",
|
|
14
|
+
"css-loader": "^7.1.2",
|
|
15
|
+
"cssnano-preset-advanced": "^7.0.10",
|
|
19
16
|
"html-inline-css-webpack-plugin": "^1.11.2",
|
|
20
17
|
"html-inline-script-webpack-plugin": "^3.2.1",
|
|
21
18
|
"html-loader": "^5.0.0",
|
|
@@ -26,42 +23,43 @@
|
|
|
26
23
|
"memory-fs": "^0.5.0",
|
|
27
24
|
"mini-css-extract-plugin": "^2.8.0",
|
|
28
25
|
"null-loader": "^4.0.1",
|
|
29
|
-
"css-minimizer-webpack-plugin": "^
|
|
26
|
+
"css-minimizer-webpack-plugin": "^7.0.2",
|
|
30
27
|
"postcss": "^8.4.33",
|
|
28
|
+
"postcss-discard-comments": "^7.0.5",
|
|
31
29
|
"postcss-import": "^16.0.0",
|
|
32
30
|
"postcss-import-webpack-resolver": "^1.0.1",
|
|
33
|
-
"postcss-loader": "^8.
|
|
34
|
-
"postcss-nested": "^
|
|
35
|
-
"postcss-
|
|
31
|
+
"postcss-loader": "^8.2.0",
|
|
32
|
+
"postcss-nested": "^7.0.2",
|
|
33
|
+
"postcss-normalize-whitespace": "^7.0.1",
|
|
34
|
+
"postcss-preset-env": "^10.4.0",
|
|
36
35
|
"postcss-scss": "^4.0.9",
|
|
37
36
|
"module-from-string": "^3.3.0",
|
|
38
37
|
"raw-loader": "^4.0.2",
|
|
39
|
-
"remark-code-import": "^
|
|
40
|
-
"remark-embed-images": "^
|
|
41
|
-
"
|
|
38
|
+
"remark-code-import": "^1.2.0",
|
|
39
|
+
"remark-embed-images": "^5.0.0",
|
|
40
|
+
"rehype-unwrap-images": "^1.0.0",
|
|
42
41
|
"resolve-url-loader": "^5.0.0",
|
|
43
42
|
"source-map-loader": "^5.0.0",
|
|
44
|
-
"style-loader": "^
|
|
43
|
+
"style-loader": "^4.0.0",
|
|
45
44
|
"terser-webpack-plugin": "^5.3.10",
|
|
46
45
|
"webpack": "^5.90.1",
|
|
47
|
-
"webpack-bundle-analyzer": "^
|
|
48
|
-
"webpack-cli": "^
|
|
49
|
-
"webpack-dev-server": "^
|
|
50
|
-
"serve": "^14.2.
|
|
46
|
+
"webpack-bundle-analyzer": "^5.0.1",
|
|
47
|
+
"webpack-cli": "^6.0.1",
|
|
48
|
+
"webpack-dev-server": "^5.2.2",
|
|
49
|
+
"serve": "^14.2.5"
|
|
51
50
|
},
|
|
52
51
|
"devDependencies": {
|
|
53
|
-
"@enhanced-dom/lint": "
|
|
52
|
+
"@enhanced-dom/lint": "~0.2.1",
|
|
54
53
|
"@types/html-webpack-plugin": "^3.2.9",
|
|
55
|
-
"@types/loader-utils": "^
|
|
54
|
+
"@types/loader-utils": "^3.0.0",
|
|
56
55
|
"@types/memory-fs": "^0.3.7",
|
|
57
56
|
"@types/optimize-css-assets-webpack-plugin": "^5.0.8",
|
|
58
|
-
"@types/terser-webpack-plugin": "^5.2.0",
|
|
59
57
|
"@types/webpack": "^5.28.5",
|
|
60
|
-
"@types/webpack-bundle-analyzer": "^4.
|
|
61
|
-
"typescript": "^5.
|
|
58
|
+
"@types/webpack-bundle-analyzer": "^4.7.0",
|
|
59
|
+
"typescript": "^5.9.3"
|
|
62
60
|
},
|
|
63
61
|
"engines": {
|
|
64
|
-
"node": ">=
|
|
62
|
+
"node": ">=20",
|
|
65
63
|
"npm": ">=10"
|
|
66
64
|
}
|
|
67
65
|
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
const style_loader_1 = __importDefault(require("style-loader"));
|
|
6
|
-
const lodash_1 = require("lodash");
|
|
7
|
-
const cjs_1 = require("@enhanced-dom/css/cjs");
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
9
|
-
const loader = function () { };
|
|
10
|
-
loader.pitch = function pitch(remainingRequest) {
|
|
11
|
-
if (this.cacheable) {
|
|
12
|
-
this.cacheable();
|
|
13
|
-
}
|
|
14
|
-
const result = style_loader_1.default.pitch.call(this, remainingRequest);
|
|
15
|
-
const index = result.indexOf('var update = API(content, options)');
|
|
16
|
-
if (index <= -1)
|
|
17
|
-
return result;
|
|
18
|
-
const insertIndex = index - 1;
|
|
19
|
-
const stylesheetName = (0, lodash_1.uniqueId)('stylesheet');
|
|
20
|
-
const insertAttr = `
|
|
21
|
-
options.attributes = options.attributes || {}
|
|
22
|
-
options.attributes["${cjs_1.STYLESHEET_ATTRIBUTE_NAME}"] = "${stylesheetName}";
|
|
23
|
-
`;
|
|
24
|
-
return result.slice(0, insertIndex) + insertAttr + result.slice(insertIndex) + `export const _stylesheetName = "${stylesheetName}";`;
|
|
25
|
-
};
|
|
26
|
-
module.exports = loader;
|
|
27
|
-
//# sourceMappingURL=ExposeCssSourceLoader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExposeCssSourceLoader.js","sourceRoot":"./","sources":["loaders/ExposeCssSourceLoader.ts"],"names":[],"mappings":";;;;AAAA,gEAAsC;AACtC,mCAAiC;AACjC,+CAAiE;AAEjE,gEAAgE;AAChE,MAAM,MAAM,GAAG,cAAa,CAAC,CAAA;AAE7B,MAAM,CAAC,KAAK,GAAG,SAAS,KAAK,CAAC,gBAAwB;IACpD,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;QACnB,IAAI,CAAC,SAAS,EAAE,CAAA;IAClB,CAAC;IACD,MAAM,MAAM,GAAW,sBAAW,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAA;IACrE,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,oCAAoC,CAAC,CAAA;IAClE,IAAI,KAAK,IAAI,CAAC,CAAC;QAAE,OAAO,MAAM,CAAA;IAC9B,MAAM,WAAW,GAAG,KAAK,GAAG,CAAC,CAAA;IAC7B,MAAM,cAAc,GAAG,IAAA,iBAAQ,EAAC,YAAY,CAAC,CAAA;IAC7C,MAAM,UAAU,GAAG;;0BAEK,+BAAyB,SAAS,cAAc;GACvE,CAAA;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,GAAG,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,mCAAmC,cAAc,IAAI,CAAA;AACtI,CAAC,CAAA;AAED,iBAAS,MAAM,CAAA","sourcesContent":["import styleLoader from 'style-loader'\nimport { uniqueId } from 'lodash'\nimport { STYLESHEET_ATTRIBUTE_NAME } from '@enhanced-dom/css/cjs'\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst loader = function () {}\n\nloader.pitch = function pitch(remainingRequest: string) {\n if (this.cacheable) {\n this.cacheable()\n }\n const result: string = styleLoader.pitch.call(this, remainingRequest)\n const index = result.indexOf('var update = API(content, options)')\n if (index <= -1) return result\n const insertIndex = index - 1\n const stylesheetName = uniqueId('stylesheet')\n const insertAttr = `\n options.attributes = options.attributes || {}\n options.attributes[\"${STYLESHEET_ATTRIBUTE_NAME}\"] = \"${stylesheetName}\";\n `\n return result.slice(0, insertIndex) + insertAttr + result.slice(insertIndex) + `export const _stylesheetName = \"${stylesheetName}\";`\n}\n\nexport = loader\n"]}
|