Closed torrinworx closed 17 minutes ago
Hmmm, even with that pass through it doesn't seem to parse the functions returned by default from those files as components, something like this:
const Page = pages[matchedPath];
return <Page {...{state, ...p.props}}/>
Results in:
Caused by: Error: Objects passed to destam-dom must be iterable (like arrays). Maybe you passed in a raw object?
logging node
results in this:
Node {
type: 'MetaProperty',
start: 321,
end: 332,
loc: SourceLocation {
start: Position { line: 8, column: 16, index: 321 },
end: Position { line: 8, column: 27, index: 332 },
filename: undefined,
identifierName: undefined
},
meta: Node {
type: 'Identifier',
start: 321,
end: 327,
loc: SourceLocation {
start: [Position],
end: [Position],
filename: undefined,
identifierName: 'import'
},
name: 'import'
},
property: Node {
type: 'Identifier',
start: 328,
end: 332,
loc: SourceLocation {
start: [Position],
end: [Position],
filename: undefined,
identifierName: 'meta'
},
name: 'meta'
}
}
You were actually on the right track. I think we just ignore the expression. The reason it's still not working is because if you look at the documentation as you've posted yourself, you can see it transforms to:
// code produced by vite
const modules = {
'./dir/foo.js': () => import('./dir/foo.js'),
'./dir/bar.js': () => import('./dir/bar.js'),
}
It lowers the global import to dynamic imports (lower is compiler speak for transforming into a simpler representation). Dynamic imports return a promise. Therefore, you must await them before you actually use them with destam-dom
.
Release v0.9.2 fixes this
Vite supports global imports that let you import multiple modules. That functionality seems to be getting caught by the transform util:
https://github.com/Nefsen402/destam-dom/blob/2a14dcbeafdb8030eb10f3c429e970a21a617183/transform/util.js#L415
Is it possible to do something like this in /transform/util.js:
Right now using import.meta.glob like this:
Get's caught: