-
-
Notifications
You must be signed in to change notification settings - Fork 432
Conversation
Oh, and another problem/TODO — output filenames aren't hashed, which causes the usual caching nonsense with service workers. We could use rollup-plugin-hash but then we wouldn't be able to reliably determine where the entry point was in the output |
I don't know whether this will help, but Terser does have a |
Does rollup/rollup#2405 solve that? You could write a tiny custom plugin that adds a function for the |
Doesn't the |
Very exciting to see rollup support underway! I've been playing a lot with Closure Compiler + rollup + Svelte recently so maybe there's something I can help with there. I've been able to get reasonably simple Svelte apps to compile (e.g. this project) but it would be interesting trying to get Sapper bundles compiling. |
Oh, fantastic. That's definitely going to help if we end up using native modules (currently trying to figure out if we're better off with AMD/loadz0r or ESM/Shimport — currently leaning towards Shimport).
Huh, you'd think I'd have known about that. Yes, probably. Not so sure about the
Ah, nice — I'm using Terser currently because of the bug I mentioned, but I'd like to use Closure if it turns out to have better compression |
rollup.config.js
Outdated
@@ -36,7 +37,7 @@ export default [ | |||
`src/webpack.ts` | |||
], | |||
output: { | |||
dir: 'dist', | |||
dir: path.join(__dirname, 'dist'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually use dir : "./dist"
and it works fine in windows, if it helps at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh. will try that next. thanks!
I don't get it. It's just not creating a |
I'll try to pull this down and test locally to see if I can get you some more windows data points. Debugging via CI is the worst. |
Thanks — I've just figured it out. On Windows, an |
Interesting, I've never run into anything like that before! |
Ok, we have a working Sapper app built with Rollup, using native JavaScript modules: https://sapper-template-rollup.now.sh/ If the tests pass (come on AppVeyor, don't let me down now) then I'll merge this in and release 0.18. Since Rollup doesn't support HMR, I'm going to add livereload functionality to the dev server in a follow-up release soon after. Will open a separate issue for that. |
Great success! Seriously, this is cool. Will I be able to switch my current webpack project to Rollup? |
@elcobvg yes! As long as your app is capable of being built by Rollup (a handful of modules, sadly, just can't be converted from CommonJS to ESM because they abuse inline This repo has a sample set of Rollup configs to crib from: https://github.com/Rich-Harris/sapper-template-rollup/tree/master/rollup (will be moving it into the sveltejs org soon). Let me know if you run into any problems! |
Thanks, I will try it out and see how it goes. If I learn anything that's worth reporting, I'll do so. |
Further reducing the already small builds, it is so impressive. (Though perhaps a bit unsportsmanlike to "run up the score" :-) ) |
@Rich-Harris, I get these errors when firing up:
Which very likely has to do with the fact that I'm using regexp patterns in my routes (see: #283 ) (FWIW, the errors come from snapdragon:parser) |
Experimented with using Closure Compiler today but ran into some blockers due to upstream issues. Opened an issue in the template to track this: https://github.com/sveltejs/sapper-template-rollup/issues/5. The upstream issues are: |
@elcobvg this is an issue in Rollup itself: rollup/rollup#2432. It can be worked around in the meantime by explicitly disabling globbing in your Rollup configs — add the following to watch: {
chokidar: {
disableGlobbing: true
}
} @maxmilton nice, thanks for raising that. In Sapper's case Closure does need to be able to parse dynamic |
@Rich-Harris that does indeed solve the problem. Thanks a lot! |
Making a start on #130. Early signs are encouraging — builds are, predictably, smaller and faster.
For webpack users, nothing should change. Internally, a few things are different:
WebpackCompiler
andRollupCompiler
classes that abstract away the underlying bundler with a common interface, used indev
andbuild
rollup
directory, and if so create aRollupCompiler
for client, server and (optionally) service worker. If not, it falls back to webpackSeveral issues remain:
<script>
hastype="module"
, because Rollup is generating ESM. This works brilliantly in Chrome, where dynamicimport(...)
is supported, but not in Firefox wheretype="module"
works fine, but dynamic import causes "SyntaxError: expected expression, got keyword 'import'". It would be wonderful to use native module loaders where available, but we might have to settle for loadz0r for the next few months, unless we can do some cool differential bundling stuff.You can see how the config requirements change in sapper-template-rollup — see the new
rollup
directory, which replaceswebpack
. No source code changes are required.