Skip to content

Commit

Permalink
use rcompat's File#import to ensure Windows compat
Browse files Browse the repository at this point in the history
  • Loading branch information
terrablue committed Feb 12, 2024
1 parent b0258dc commit e29bb8f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
3 changes: 1 addition & 2 deletions packages/frontend/src/frontends/common/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ export default config => {
});
}

const imported = (await import(root)).default;
const { body, head } = render(imported, {
const { body, head } = render(await root.import("default"), {
components: components.map(({ component }) => component),
...shared,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/frontends/common/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ const get_error = (error, path) =>
: ErrorInComponent;

export default async path =>
tryreturn(_ => import(`${path}.js`))
tryreturn(_ => File.import(`${path}.js`))
.orelse(error => get_error(error, `${path}.js`)(path.name, path, error));
2 changes: 1 addition & 1 deletion packages/primate/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default async (log, root, config) => {
root,
log,
error: {
default: await error.exists() ? (await import(error)).default : undefined,
default: await error.exists() ? await error.import("default") : undefined,
},
handlers: { ...handlers },
extensions: {
Expand Down
6 changes: 3 additions & 3 deletions packages/primate/src/loaders/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export default async ({
const objects = directory === undefined ? [] : await Promise.all(
(await File.collect(directory, /^.*.js$/u, { recursive }))
.filter(filter)
.map(async path => [
`${path}`.replace(directory, _ => "").slice(1, -ending.length),
await import(path),
.map(async file => [
`${file}`.replace(directory, _ => "").slice(1, -ending.length),
await file.import(),
]));
warn && await directory.exists() && empty(log)(objects, name, directory);

Expand Down
2 changes: 1 addition & 1 deletion packages/primate/src/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const get_config = async root => {
const config = root.join(name);
return await config.exists()
? tryreturn(async _ => {
const imported = (await import(config)).default;
const imported = await config.import("default");

(imported === undefined || Object.keys(imported).length === 0) &&
errors.EmptyConfigFile.warn(logger, config);
Expand Down
4 changes: 2 additions & 2 deletions packages/store/src/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export default ({
// accept only lowercase-first directories in store path
.filter(([name]) =>
name.split("/").slice(0, last).every(part => /^[a-z]/u.test(part)))
.map(async ([store, path]) => {
const exports = await import(path);
.map(async ([store, file]) => {
const exports = await file.import();
const schema = transform(exports.default, entry => entry
.filter(([property, type]) => valid(type, property, store)));

Expand Down

0 comments on commit e29bb8f

Please sign in to comment.