cramforce/splittable

Strings are inlined into entry modules instead of _base.js

Closed this issue · 1 comments

Hey there,

I have an issue with how CSS exported from modules is inlined. This might be an issue for closure compiler instead of splittable but I wanted to get your take on it first. See below for details:

# a.js
import css from './css-module';

const style = document.createElement('style');
style.textContent = css;
document.body.appendChild(style);
# b.js
import css from './css-module';
const style = document.createElement('style');
style.textContent = css;
document.body.appendChild(style);
# css-module.js

const css = `
...huge amount of css
`;

export default css;

Expected behaviour:

  • The string exported from css-module should be extracted into the _base.js and shared between the a.js and b.js entry point modules

Actual behaviour:

  • The string is inlined into a.js and b.js duplicating the contents across both modules.

Very interesting problem! Like really! But please file in closure compiler
repo. It isn't entirely clear what is the right thing to do. Often keeping
base smaller is better even if delivering more bytes in total.

On Nov 17, 2016 6:04 PM, "Cameron Westland" notifications@github.com
wrote:

Hey there,

I have an issue with how CSS exported from modules is inlined. This might
be an issue for closure compiler instead of splittable but I wanted to get
your take on it first. See below for details:

a.jsimport css from './css-module';

const style = document.createElement('style');style.textContent = css;document.body.appendChild(style);

b.js

import css from './css-module';
const style = document.createElement('style');
style.textContent = css;
document.body.appendChild(style);

css-module.js

const css = ...huge amount of css;

export default css;

Expected behaviour:

  • The string exported from css-module should be extracted into the
    _base.js and shared between the a.js and b.js entry point modules

Actual behaviour:

  • The string is inlined into a.js and b.js duplicating the contents
    across both modules.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#12, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAFeT5sfUFtpRoszzwuJKGPsHi0V_7kcks5q_QeTgaJpZM4K2Cgt
.