-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Webpack usage #17
Comments
@vladshcherbin it should work in both, although I haven't used it with Webpack. It's likely due to It'd help if you posted the errors you were receiving. |
Yeah, I'm trying to figure out the correct usage. So, I'm installing trilogy & sqlite3. The app is running locally. app.js import React from 'react'
import ReactDOM from 'react-dom'
import Trilogy from 'trilogy'
ReactDOM.render(
<p>h2</p>,
document.getElementById('app')
) The errors are: errors
|
I can compile with no errors if I use externals: [
'sqlite3',
'knex',
'trilogy'
] But if I'm not mistaken, none of this modules will be bundled in the app. |
I'd suggest either adding Trilogy and sqlite3 to your externals or using sql.js as your backend. Is this for a deployed client-side app or something in Electron / nw.js? |
I'm trying to use it with an Electron app. |
Yep, they won't be bundled if you specify them as externals. But it's not possible to bundle sqlite3 at all since it's a native C binding. See TryGhost/node-sqlite3#698. sql.js might bundle however I haven't tried it. It's a pure JS alternative and I'd think it would work fairly smoothly. You can do this by passing All that said, if you're making an Electron app bundling isn't strictly necessary. It can help with optimization, sure, but isn't the biggest bottleneck you'll face. A few externals is to be expected. fyi: I updated the title since this is related more to Webpack than to Trilogy / Electron renderer, but let me know if you feel that's not accurate |
Yes, The main question is - how do you use it in |
It should work the same in renderer as it does in main since renderer is basically the usual webpage extended with node, so just |
Okay, I put externals: [
'sqlite3',
'knex'
] Still have an error:
|
If I use bare electron, even w/o webpack: <!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<p>hey</p>
<script>
const Trilogy = require('trilogy')
</script>
</body>
</html> I also see this error in console:
|
Ah I see an issue there - if you're not using sql.js I shouldn't I've opened a new issue (see below) for this since it's sort of a tangent from the original topic of 'webpack'. |
Sure, I'll try to use |
Hm, I changed externals: [
'knex'
] As a result, there are no more sqlite errors as expected. Webpack bundles with no errors. Unfortunately, when I import Uncaught ReferenceError: knex is not defined If I remove errors
If I don't use webpack, I don't have any errors: <!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<p>hey</p>
<script>
const Trilogy = require('trilogy')
</script>
</body>
</html> Not sure what to try now 😔 |
All the Webpack errors from knex are because it statically analyzes every As for the |
Okay, probably I don't understand what I should bundle for Electron and what I should not. With web apps I bundle all modules that I want to use on the client. So, if I want to use What's about electron, why can I use this: externals: [
'knex',
'trilogy',
'react',
'react-dom'
]
// app.js
import React from 'react'
import ReactDOM from 'react-dom'
import Trilogy from 'trilogy'
ReactDOM.render(
<p>h2</p>,
document.getElementById('app')
) and still be able to import it and use in renderer ? |
You're thinking of Electron as a client / server relationship, which is close and is a sometimes useful comparison. But it's really more cohesive than that. The renderer can This Electron doc ( and others in the repo about usage ) may help you: Synopsis. This is why it's not as common to use Webpack / Rollup / bundles with Electron apps. I'm going to close this since its external, but thanks for uncovering the other problem! |
@citycide thank you a lot for help 😉 |
Hey, where is trilogy supposed to be used, in main or in renderer?
I tried it in renderer, but webpack gives me errors.
The text was updated successfully, but these errors were encountered: