-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloader.js
More file actions
24 lines (21 loc) · 798 Bytes
/
Copy pathloader.js
File metadata and controls
24 lines (21 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const { parseSource } = require('./build');
const { extname, basename } = require('path');
const { getOptions } = require('loader-utils');
const { snakeToCamel, capitalize } = require('./build/utils');
module.exports = function (html, sourceMap, meta) {
let { comments = false, format = 'esm', directives = [] } = getOptions(this) || {};
const ext = extname(this.resourcePath);
const moduleName = capitalize(snakeToCamel(basename(this.resourcePath, ext)));
const { code, map, error } = parseSource(html, {
filePath: this.resourcePath,
compilerOptions: {
comments, format: /^(esm|cjs)$/i.test(format) ? format : 'esm',
minify: false, moduleName, optimize: false
},
directives
});
if (error) {
throw error;
}
this.callback(null, code, map, meta);
};