workspace
stringclasses 4
values | channel
stringclasses 4
values | text
stringlengths 1
3.93k
| ts
stringlengths 26
26
| user
stringlengths 2
11
|
---|---|---|---|---|
elmlang
|
general
|
Suggesting its a combined bundle.
|
2019-02-15T08:26:12.438800
|
Agustin
|
elmlang
|
general
|
Apologies for wasting your time
|
2019-02-15T08:26:21.439000
|
Agustin
|
elmlang
|
general
|
It's ok <@Agustin>, I really appreciate you taking the time to try and help :slightly_smiling_face:
|
2019-02-15T08:28:32.439200
|
Antonette
|
elmlang
|
general
|
(and I'm sorry for having been a bit obnoxious originally)
|
2019-02-15T08:28:47.439400
|
Antonette
|
elmlang
|
general
|
(I guess it might apply to Parcel users as well, if Parcel uses node-elm-compiler too, haven't tried it)
|
2019-02-15T08:30:12.441300
|
Nana
|
elmlang
|
general
|
<@Tamra> Thank you for the fast response. This miss placed and too simple question was part of my presentation on :elm: . I asked the question in the middle of the presentation. The point of the question was to point out how polite the elm-community is and how fast you can get help even with stupid questions that would normally almost anywhere else get a response like "did you try to google it".
|
2019-02-15T08:30:31.441400
|
Logan
|
elmlang
|
general
|
You did very well :clap:
|
2019-02-15T08:30:48.441600
|
Logan
|
elmlang
|
general
|
Actually, the audience suspected that this was arranged and you got paid :smile:
|
2019-02-15T08:32:34.441900
|
Logan
|
elmlang
|
general
|
And where does your `Main.elm` live <@Antonette>? The one, you are trying to `require` I mean
|
2019-02-15T08:47:16.442600
|
Lynne
|
elmlang
|
general
|
Do I understand correctly that you have single `Main.elm` per page? Meaning, there is basically an Elm app per page (this follows from your original post if I got it right)
|
2019-02-15T08:48:35.443200
|
Lynne
|
elmlang
|
general
|
That's the problem: I don't have a `Main.elm`. I have *many* such files in my `webpack/client/Pages` directory.
|
2019-02-15T08:48:37.443400
|
Antonette
|
elmlang
|
general
|
I see
|
2019-02-15T08:48:42.443700
|
Lynne
|
elmlang
|
general
|
So you have to require and `init` each of them separately
|
2019-02-15T08:48:53.444100
|
Lynne
|
elmlang
|
general
|
The problem is that I don't have an SPA (yet) and the cost of migrating all those separate pages to an SPA is too high for now.
|
2019-02-15T08:49:16.444600
|
Antonette
|
elmlang
|
general
|
Indeed :slightly_smiling_face:
|
2019-02-15T08:49:21.444800
|
Antonette
|
elmlang
|
general
|
I understand, that should not be a problem
|
2019-02-15T08:49:29.445100
|
Lynne
|
elmlang
|
general
|
I would rather it wasn't too :wink:
|
2019-02-15T08:49:42.445500
|
Antonette
|
elmlang
|
general
|
Webpack simply follows your `require` statements and when it discovers an Elm file, it hands over its processing to `elm-webpack-loader`
|
2019-02-15T08:50:14.445800
|
Lynne
|
elmlang
|
general
|
What is everyone's opinion on calling update within update to reuse behaviour? I've found it very useful as it creates less indirection than moving the return value in a function and reusing that function.
|
2019-02-15T08:50:16.446100
|
Dayna
|
elmlang
|
general
|
Maybe we messed up on that front.
|
2019-02-15T08:50:31.446200
|
Antonette
|
elmlang
|
general
|
We factored the part which requires the files.
|
2019-02-15T08:50:39.446400
|
Antonette
|
elmlang
|
general
|
So if you `require('./Pages/MySuperPage/Main')` (or whatever your page entry module is called) you should be able to call `init` on the required object
|
2019-02-15T08:51:20.446600
|
Lynne
|
elmlang
|
general
|
```
function withNodeAndPage(nodeId, pageName, doStuffWith) {
const node = document.getElementById(nodeId);
if (node) {
const pages = require("./Pages/" + pageName + ".elm").Elm.Pages;
const page = pageName
.split("/")
.reduce(
function(accumulator, property) { return accumulator[property]; },
pages
);
doStuffWith(node, page);
}
};
```
|
2019-02-15T08:51:38.446800
|
Antonette
|
elmlang
|
general
|
do it all the time
|
2019-02-15T08:52:12.447100
|
Rosa
|
elmlang
|
general
|
Emmm... Do you have your pages defined as `module Pages.XXXX`?
|
2019-02-15T08:52:42.447200
|
Lynne
|
elmlang
|
general
|
Yep.
|
2019-02-15T08:52:51.447400
|
Antonette
|
elmlang
|
general
|
I see
|
2019-02-15T08:52:54.447600
|
Lynne
|
elmlang
|
general
|
But anyways, does this function work?
|
2019-02-15T08:53:11.447800
|
Lynne
|
elmlang
|
general
|
Sure.
|
2019-02-15T08:53:16.448000
|
Antonette
|
elmlang
|
general
|
It is rather different from what you posted above
|
2019-02-15T08:53:19.448200
|
Lynne
|
elmlang
|
general
|
Ok, so do you still have the problem?
|
2019-02-15T08:53:24.448400
|
Lynne
|
elmlang
|
general
|
(before I attempted to add the configuration for webpack that is)
|
2019-02-15T08:53:29.448600
|
Antonette
|
elmlang
|
general
|
Just so we're on the same page:
- my initial problem is that every time a file is touched, webpack recompiles every page which takes a lot of time ; I'd rather it only recompiled only the pages that are concerned
- in order to attempt to solve the problem, I modified my configuration following the advice given to use the `files` option and attempting to load only one file (the `elm/Main`) ; apparently that does not work since there is no `elm/Main` in my project
|
2019-02-15T08:56:11.448900
|
Antonette
|
elmlang
|
general
|
Aha, so we can drop the second part and only focus on the first one
|
2019-02-15T08:57:04.449100
|
Lynne
|
elmlang
|
general
|
Sure.
|
2019-02-15T08:57:11.449300
|
Antonette
|
elmlang
|
general
|
So, I stashed all the changes, and it compiles just fine (if unbearably slowly).
|
2019-02-15T08:57:49.449500
|
Antonette
|
elmlang
|
general
|
I see
|
2019-02-15T08:58:06.449700
|
Lynne
|
elmlang
|
general
|
I must admit I don't have ideas regarding this
|
2019-02-15T08:58:44.449900
|
Lynne
|
elmlang
|
general
|
In my setup there is a single entry point
|
2019-02-15T08:59:03.450100
|
Lynne
|
elmlang
|
general
|
Arf.
|
2019-02-15T08:59:13.450300
|
Antonette
|
elmlang
|
general
|
I wonder if you can export your apps
|
2019-02-15T09:03:00.450500
|
Agustin
|
elmlang
|
general
|
And let elm do the compile
|
2019-02-15T09:03:05.450700
|
Agustin
|
elmlang
|
general
|
eg have a main module that exports the individual pages
|
2019-02-15T09:03:23.450900
|
Agustin
|
elmlang
|
general
|
Maaaaybe? How would one go about it?
|
2019-02-15T09:03:56.451100
|
Antonette
|
elmlang
|
general
|
(because I certainly would try this but I don't know where to start)
|
2019-02-15T09:04:11.451300
|
Antonette
|
elmlang
|
general
|
I had this idea for building a page from the contents of a database and building the DOM elements on the fly, but my model would have included something like `thePage: List (Html msg)` which is disallowed. Am I barking up the wrong tree?
|
2019-02-15T09:23:32.453400
|
Carmon
|
elmlang
|
general
|
`Browser.document` is what you want
|
2019-02-15T09:26:08.453700
|
Danika
|
elmlang
|
general
|
The view function now has the following signature: `view : model -> Document msg` where document is:
```type alias Document msg =
{ title : String
, body : List (Html msg)
}```
|
2019-02-15T09:27:01.454400
|
Danika
|
elmlang
|
general
|
<@Carmon> storing `Html msg` in your model it generally a bad idea, it's better to keep your `Html msg` in your `view` and store a value in your model that you can calculate that `Html msg` from.
|
2019-02-15T09:29:29.455700
|
Earlean
|
elmlang
|
general
|
Oh yeah, and that :')
|
2019-02-15T09:32:29.456000
|
Danika
|
elmlang
|
general
|
What's the reasoning behind that
|
2019-02-15T09:32:44.456200
|
Danika
|
elmlang
|
general
|
OK - Thank you! I think I get it
|
2019-02-15T09:34:06.456500
|
Carmon
|
elmlang
|
general
|
Really? :joy:
|
2019-02-15T09:34:27.456600
|
Tamra
|
elmlang
|
general
|
Glad to help!
|
2019-02-15T09:34:38.456800
|
Tamra
|
elmlang
|
general
|
Storing html in the model kind of breaks the whole reactive/declarative UI idea
|
2019-02-15T09:39:07.457000
|
Nana
|
elmlang
|
general
|
Yup. An answer in a minute or less. That was great :grinning:
|
2019-02-15T09:41:42.457200
|
Logan
|
elmlang
|
general
|
Plus I'm guessing maybe there could be serialization issues depending on the internal implementation of the html lib?
|
2019-02-15T09:42:06.457400
|
Nana
|
elmlang
|
general
|
Not all UI needs to be reactive.
|
2019-02-15T09:44:04.457600
|
Danika
|
elmlang
|
general
|
I think really the point is to not store _functions_ in the model, not so much html in particular
|
2019-02-15T09:45:44.457900
|
Danika
|
elmlang
|
general
|
But then you're no longer following the Elm Architecture
|
2019-02-15T09:46:59.458100
|
Nana
|
elmlang
|
general
|
Although maybe some clever stuff could be achieved by storing html :thinking_face: could be worth exploring
|
2019-02-15T09:48:39.458300
|
Nana
|
elmlang
|
general
|
But if it's for performance reasons, `Html.lazy` would usually be a better (and faster) solution
|
2019-02-15T09:50:15.458500
|
Nana
|
elmlang
|
general
|
<@Agustin>?
|
2019-02-15T09:53:07.458900
|
Antonette
|
elmlang
|
general
|
Well a normal module with the pages exposed, but I think it would depend if the compiler supports it
|
2019-02-15T09:55:11.459100
|
Agustin
|
elmlang
|
general
|
compiler needs a `main`.
<@Antonette> I assume you've tried the `files` approach pointing at all files that have a `main`?
|
2019-02-15T09:56:08.459400
|
Huong
|
elmlang
|
general
|
You mean using the `files` option in `webpack.config.js`? When I did just try what I explained that did not work with it (and I did not have a special main file but multiple page files).
|
2019-02-15T09:59:02.459700
|
Antonette
|
elmlang
|
general
|
<@Agustin> I don't quite know what the normal module with the pages exposed would look like ; if you can point to an example I'd be happy to try :)
|
2019-02-15T10:00:46.460000
|
Antonette
|
elmlang
|
general
|
Yeah, I think the core issue is that you want elm-webpack-load to understand that `require("./Pages/App1.elm")` should be resolved to the same bundle as `require("./Pages/App2.elm")`. I don't know if `elm-webpack-loader` has some magic around that :thinking_face:
|
2019-02-15T10:03:50.460200
|
Huong
|
elmlang
|
general
|
otoh
|
2019-02-15T10:04:29.460400
|
Huong
|
elmlang
|
general
|
you don't need to `require` them separately
|
2019-02-15T10:04:40.460600
|
Huong
|
elmlang
|
general
|
<https://github.com/elm-community/elm-webpack-loader#files-default---path-to-required-file>
So if I follow that, having `files` with a list of the actual Elm modules that expose a `Main`, you can import any one of those and the resulting `Elm` export should have all the modules in it
|
2019-02-15T10:05:49.460800
|
Huong
|
elmlang
|
general
|
Cool, thanks <@Huong> :) trying that right away.
|
2019-02-15T10:14:19.461000
|
Antonette
|
elmlang
|
general
|
Ok, so I did something similar to what I had done last time:
```
// in webpack.config.js
{
test: /\.elm$/,
exclude: [/elm-stuff/, /node_modules/],
loader: 'elm-webpack-loader',
options: {
cwd: 'webpack/client',
files: [
path.resolve(__dirname, "webpack/client/Pages/SomeIndex.elm"),
path.resolve(__dirname, "webpack/client/Pages/OtherIndex.elm")
]
}
}
// in my index.js
const SomeIndex = require("./Pages/SomeIndex.elm").Elm.Pages.SomeIndex;
const OtherIndex = require("./Pages/OtherIndex.elm").Elm.Pages.OtherIndex;
...
```
|
2019-02-15T10:27:52.461300
|
Antonette
|
elmlang
|
general
|
Good thing: it compiles and it works.
|
2019-02-15T10:28:40.461600
|
Antonette
|
elmlang
|
general
|
Less good thing: it re-compiles everything every time I change one file, even the modules I don't need re-compiled :confused:
|
2019-02-15T10:29:21.461800
|
Antonette
|
elmlang
|
general
|
(so it's just more configuration that seems to have no impact on what I'm trying to achieve as far as I can tell)
|
2019-02-15T10:29:49.462000
|
Antonette
|
elmlang
|
general
|
Nota bene: it still works even if I give an empty array to the `files` option in `webpack.config.js`. Is this option even doing anything relevant?
|
2019-02-15T10:33:55.462200
|
Antonette
|
elmlang
|
general
|
Quick check: Are you still `require`ing them separately, or do you have one single `require`, whose value is reused?
|
2019-02-15T10:35:04.462400
|
Huong
|
elmlang
|
general
|
I am still requireing them separately. I don't know how to do all in one require.
|
2019-02-15T10:35:33.462600
|
Antonette
|
elmlang
|
general
|
(because I don't know what the string I should give this special one-time require should be ; I tried `"elm/Main"`, `"elm/Main.elm"`, `"Main.elm"` `"Main"`, `"./elm/Main.elm"`, `"./elm/Main"`, `"./Main.elm"`, `"./Main"`, all to no avail)
|
2019-02-15T10:37:14.462800
|
Antonette
|
elmlang
|
general
|
```const Pages = require("./Pages/SomeIndex.elm").Elm.Pages;
SomeIndex = Pages.SomeIndex;
OtherIndex = Pages.OtherIndex;
``` I think something like this
|
2019-02-15T10:42:26.463100
|
Huong
|
elmlang
|
general
|
Yep. Nope. I only have `SomeIndex` in `Pages` and not `OtherIndex`.
|
2019-02-15T10:43:12.463300
|
Antonette
|
elmlang
|
general
|
Hm it _should_ have both :thinking_face: (at least, according to the `elm-webpack-loader` docs)
|
2019-02-15T10:45:23.463500
|
Huong
|
elmlang
|
general
|
Assuming those are up-to-date and not buggy to begin with :confused:
|
2019-02-15T10:45:51.463800
|
Antonette
|
elmlang
|
general
|
(which I'm beginning to reasonably doubt to be honest :sweat_smile:)
|
2019-02-15T10:46:19.464000
|
Antonette
|
elmlang
|
general
|
Since it still works (albeit needing multiple require) when I empty the `files` option array, maybe the paths I was giving it are failing silently?
|
2019-02-15T10:47:40.464200
|
Antonette
|
elmlang
|
general
|
Does anyone know if there’s a zip/unzip package yet? I wasn’t finding anything in the packages list. Since I couldn’t find one I started looking into making one but got a little stuck on how to got about implementing <https://en.wikipedia.org/wiki/DEFLATE> as it says to look at the individual bits but `elm/bytes` seems to only handle bytes. Sorry if I’m misunderstanding anything.
|
2019-02-15T10:54:42.466600
|
Chae
|
elmlang
|
general
|
<@Jana> has a tar package that might do what you need <https://package.elm-lang.org/packages/jxxcarlson/elm-tar/latest/>
|
2019-02-15T10:58:18.467100
|
Carman
|
elmlang
|
general
|
I always pull out the code for the target branch into a function and just call it from both branches
|
2019-02-15T11:03:13.467200
|
Earnest
|
elmlang
|
general
|
<https://gist.github.com/zwilias/18c2e87777197450146728e9b8626dcd>
So I adapted the examples from the repo
|
2019-02-15T11:06:46.467600
|
Huong
|
elmlang
|
general
|
added `Other.elm` (which just has `module Other exposing (main)` and `main = Html.text "foo"`)
|
2019-02-15T11:07:11.467900
|
Huong
|
elmlang
|
general
|
and in my console I see this:
|
2019-02-15T11:07:22.468100
|
Huong
|
elmlang
|
general
|
None
|
2019-02-15T11:07:37.468300
|
Huong
|
elmlang
|
general
|
So it definitely _is_ possible to get multiple Elm `main` modules with a single `require`, using the `files` option for the loader
|
2019-02-15T11:08:21.468700
|
Huong
|
elmlang
|
general
|
Thanks ; I did exactly that except for the `debug: true` (adding it right now) and that my directory structure is a bit different.
|
2019-02-15T11:14:53.468900
|
Antonette
|
elmlang
|
general
|
Could it be a version issue?
|
2019-02-15T11:15:03.469100
|
Antonette
|
elmlang
|
general
|
<https://github.com/zwilias/elm-webpack-loader-example> figured I'd bundle it up for reproduction. The `debug` shouldn't matter, but this makes it a little easier to play around with
|
2019-02-15T11:15:25.469300
|
Huong
|
elmlang
|
general
|
Yep ; I'll see what it tells me about what it does maybe I'll gain insights.
|
2019-02-15T11:15:49.469500
|
Antonette
|
elmlang
|
general
|
Cool, I hope you'll be able to figure it out! It does sound like perhaps the paths you're giving to `files` aren't quite right for whatever reason!
|
2019-02-15T11:18:20.469700
|
Huong
|
elmlang
|
general
|
Well, looks like the `debug: true` didn't do squat :confused:
|
2019-02-15T11:18:59.469900
|
Antonette
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.