mirror of
https://github.com/Terncode/pixel.horse.git
synced 2026-12-03 05:10:04 +01:00
Replace webpack with esbuild
This commit is contained in:
1 parent
7e3e2dc5b9
commit
ecb1b76891
13 files changed
+750
-7990
No files matched your search
@@ -1,28 +0,0 @@
|
||||
import { transformAsync } from '@babel/core';
|
||||
import linkerPlugin from '@angular/compiler-cli/linker/babel';
|
||||
import { needsLinking } from '@angular/compiler-cli/linker';
|
||||
|
||||
export default function angularLinkerLoader(content, map) {
|
||||
const callback = this.async();
|
||||
(async () => {
|
||||
try {
|
||||
const filename = this.resourcePath;
|
||||
if (!needsLinking(filename, content)) {
|
||||
callback(null, content, map);
|
||||
return;
|
||||
}
|
||||
// Create a fresh plugin instance per file. The linker plugin is stateful
|
||||
// and cannot be shared across concurrent transforms.
|
||||
const { code, map: resultMap } = await transformAsync(content, {
|
||||
filename,
|
||||
sourceFileName: filename,
|
||||
sourceMaps: !!this.sourceMap,
|
||||
compact: false,
|
||||
plugins: [api => linkerPlugin(api, { sourceMapping: false })],
|
||||
});
|
||||
callback(null, code, resultMap || undefined);
|
||||
} catch (err) {
|
||||
callback(err);
|
||||
}
|
||||
})();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
const path = require('path');
|
||||
const { compilePugTemplate } = require('./pug-template.cjs');
|
||||
|
||||
const angularHost = require(path.join(__dirname, '..', 'node_modules', '@angular', 'build', 'src', 'tools', 'angular', 'angular-host.js'));
|
||||
const createAngularCompilerHost = angularHost.createAngularCompilerHost;
|
||||
|
||||
angularHost.createAngularCompilerHost = function (...args) {
|
||||
const host = createAngularCompilerHost.apply(this, args);
|
||||
const readResource = host.readResource;
|
||||
host.readResource = async function (fileName) {
|
||||
return fileName.endsWith('.pug') ? compilePugTemplate(fileName) : readResource.call(this, fileName);
|
||||
};
|
||||
return host;
|
||||
};
|
||||
|
||||
global.angularPugHook = true;
|
||||
@@ -0,0 +1,14 @@
|
||||
const fs = require('fs');
|
||||
const pug = require('pug');
|
||||
const pugPluginNg = require('pug-plugin-ng');
|
||||
|
||||
function compilePugTemplate(file) {
|
||||
return pug.compile(fs.readFileSync(file, 'utf8'), {
|
||||
filename: file,
|
||||
doctype: 'html',
|
||||
compileDebug: false,
|
||||
plugins: [pugPluginNg],
|
||||
})({});
|
||||
}
|
||||
|
||||
module.exports = { compilePugTemplate };
|
||||
Reference in new issue
Block a user