mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 10:50:00 +00:00
[reorg]: Move api/sixtyfps-rs/sixtyfps-* into api/rs
This commit is contained in:
parent
2813441cd9
commit
842f75e653
95 changed files with 65 additions and 72 deletions
42
api/node/loader.mjs
Normal file
42
api/node/loader.mjs
Normal file
|
@ -0,0 +1,42 @@
|
|||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
import { URL, pathToFileURL } from 'url';
|
||||
|
||||
const extensionsRegex = /\.60$/;
|
||||
const baseURL = pathToFileURL(`${process.cwd()}/`).href;
|
||||
|
||||
export function resolve(specifier, context, defaultResolve) {
|
||||
|
||||
const { parentURL = baseURL } = context;
|
||||
|
||||
if (extensionsRegex.test(specifier)) {
|
||||
return { url: new URL(specifier, parentURL).href };
|
||||
}
|
||||
|
||||
return defaultResolve(specifier, context, defaultResolve);
|
||||
}
|
||||
|
||||
|
||||
export function getFormat(url, context, defaultGetFormat) {
|
||||
if (extensionsRegex.test(url)) {
|
||||
return {
|
||||
format: 'module'
|
||||
};
|
||||
}
|
||||
return defaultGetFormat(url, context, defaultGetFormat);
|
||||
}
|
||||
|
||||
export function transformSource(source, context, defaultTransformSource) {
|
||||
const { url, format } = context;
|
||||
|
||||
if (extensionsRegex.test(url)) {
|
||||
console.log(`This is where one can compile ${url}`)
|
||||
return {
|
||||
source: "console.log('Hey'); export function foo(x) { return x + 55 }"
|
||||
};
|
||||
}
|
||||
|
||||
// Let Node.js handle all other sources.
|
||||
return defaultTransformSource(source, context, defaultTransformSource);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue