Skip to content

Instantly share code, notes, and snippets.

@jstrimpel
jstrimpel / how.md
Last active March 16, 2018 19:27
Is it possible to have separate build processes that generate bundles that define dependencies, which can be used by an application without having to expose globals and rely on aliases?

Is it possible to have separate build processes that generate bundles that define dependencies, which can be used by an application without having to expose globals and rely on aliases?

Requirement

There are two separate build processes:

  • Core: This builds a distribution of common core dependencies
  • Component: This externalizes anything in core build

Use Case

The following two files are entry points for two different build processes. The component entry webpack config defines core as an external.

I have two modules A and B. A declares B as a dependency. B is built into a bundle and B's bundle is used as an entry for a DllPlugin bundle. A's build uses the manifest generated by B in a DllReferencePlugin config. I cannot get A's build to externalize and reference B's DLL. Below are the plugin configurations.

A

new webpack.DllReferencePlugin({
  context: 'ABSOLUTE_PATH_TO_B',
  manifest: require('ABSOLUTE_PATH_TO_B/dist/index-manifest')
})
@jstrimpel
jstrimpel / .a_use_case.md
Last active December 28, 2015 20:32
babel analytics, performance plugins
  • Capture analytics from synthetic events and gather performance metrics
  • Transform React components
@jstrimpel
jstrimpel / gist:7434663
Created November 12, 2013 17:06
I suck at regexes. I know there has to better regex for extracting all the values for a particular attribute from an of HTML string.
function getAttributeValues(html) {
var htmlSubstr = html,
match = true,
values = [],
start = 0;
while (match) {
htmlSubstr = htmlSubstr.substr(start);
match = htmlSubstr.match(/<[^>]*\s(?:some-attribute-name=["']([^"']*)["'])[^>]*>/);
if (match) {
@jstrimpel
jstrimpel / backbone collection push and unshift
Created August 2, 2013 04:03
What is the best method for handling polling activity feeds or infinite scroll in backbone collection views? I tied this into a backbone marionette collection view with an infinite scroll library. Is there a better way? Am I missing an easier way to handle these cases using a backbone collection?
var fetch = Backbone.Collection.prototype.fetch;
var reset = Backbone.Collection.prototype.reset;
Backbone.Collection.prototype.fetch = function (options) {
if (options.unshift || options.push) { // force a reset
options.reset = true;
}
return fetch.call(this, options);
};
@jstrimpel
jstrimpel / gist:6043926
Created July 20, 2013 04:56
requirejs config getting destroyed
// server start up
var requirejs = require('requirejs');
requirejs.config({
paths: {}, // bunch of paths
baseUrl: 'dirpath'
});
// request handler
// http request - much more going on here, but this is basically what happens
requirejs.optimize({ baseUrl: 'anotherdirpath', paths: {} }, function () {
@jstrimpel
jstrimpel / gist:3743562
Created September 18, 2012 14:54
Marionette Extensions
NS.Application = Marionette.Application.extend({
constructor: function () {
var that = this, events;
Marionette.Application.prototype.constructor.apply(this, arguments);
events = {
on: function (topic, func, object) {
this.vent.on(topic, func, (object ? object : undefined));
@jstrimpel
jstrimpel / gist:3354257
Created August 15, 2012 00:40
requirejs optimize build error
// main module
define(['core/text!template/main.html', 'js/foo', 'js/bar', 'js/baz'], function (template, foo, bar, baz) { });
// build.json used for optimize
{
"baseUrl": "./src/client",
"dir": "./web",
@jstrimpel
jstrimpel / gist:3321349
Created August 11, 2012 05:16
q promises in node test
var q = require('/home/wwwyzzerdd/node_modules/q'),
fs = require('fs');
var foo = function () {
var deferred = q.defer();
fs.readFile('in.txt', 'utf8', deferred.makeNodeResolver());
return deferred.promise;
};
var read = function () {
@jstrimpel
jstrimpel / gist:3227797
Created August 1, 2012 15:26
old haproxy conf; one of many variations used to get socket.io and ngnix playing well together
global
maxconn 4096
pidfile /var/run/haproxy.pid
debug
defaults
mode http
frontend all
bind 0.0.0.0:80