Skip to content

Commit

Permalink
Workaround for SASS in Web Worker
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Mar 11, 2019
1 parent b396c14 commit bb3216d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 17 deletions.
31 changes: 17 additions & 14 deletions packages/core/parcel-bundler/src/assets/SASSAsset.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,23 @@ class SASSAsset extends Asset {
? opts.indentedSyntax
: type === 'sass';

opts.importer = opts.importer || [];
opts.importer = Array.isArray(opts.importer)
? opts.importer
: [opts.importer];
opts.importer.push((url, prev, done) => {
url = url.replace(/^file:\/\//, '');
url = parseCSSImport(url);
resolver
.resolve(url, prev === 'stdin' ? this.name : prev)
.then(resolved => resolved.path)
.catch(() => url)
.then(file => done({file}))
.catch(err => done(normalizeError(err)));
});
if (!process.browser) {
// Workaround for https://github.com/sass/dart-sass/issues/621
opts.importer = opts.importer || [];
opts.importer = Array.isArray(opts.importer)
? opts.importer
: [opts.importer];
opts.importer.push((url, prev, done) => {
url = url.replace(/^file:\/\//, '');
url = parseCSSImport(url);
resolver
.resolve(url, prev === 'stdin' ? this.name : prev)
.then(resolved => resolved.path)
.catch(() => url)
.then(file => done({file}))
.catch(err => done(normalizeError(err)));
});
}

if (this.options.sourceMaps) {
opts.sourceMap = true;
Expand Down
18 changes: 18 additions & 0 deletions packages/core/repl/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
needed for self hosting:
change process.browser replacement to also remove other if case completely (for `requires`)
(scope hoisting destructuring: #2742)
(sourcemap only at end: #2427)


Out of Memory with scope hoisting or source maps


scope hoisting doesn't work:
.../parcel/packages/core/parcel-bundler/src/builtins/index.js:
node-libs-browser:
require.resolve()

require.resolve: should return module id that can be required
naive attempt breaks dynamic import

Connecting with Chrome Devtools to Chrome on Android silently prevents the execution of Web Workers
11 changes: 9 additions & 2 deletions packages/core/repl/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,11 @@ class App extends Component {
/>
<div class="file notes">
Yes, this is Parcel as a (nearly) self-hosting bundler (self-
<i>hoisting</i> doesn't work ...)<br />
<i>hoisting</i> doesn't work ...)
<br />
The Parcel portion of this page, including all compilers, is a 2MB
gzipped bundle running in a Web Worker<br />
gzipped bundle running in a Web Worker
<br />
<br />
Known issues:
<ul>
Expand All @@ -162,6 +164,11 @@ class App extends Component {
Babel would need to <code>require</code> plugins at runtime (at
least without workarounds)
</li>
<li>
SASS importing is disabled for now (
<a href="https://github.com/sass/dart-sass/issues/621">issue</a>
)
</li>
</ul>
</div>
</div>
Expand Down
5 changes: 4 additions & 1 deletion packages/core/repl/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ button:enabled:active {
font-size: 1em;
padding: 0.4em;
}
.start {
filter: brightness(80%);
}

.options > label {
padding: 0.3em;
Expand Down Expand Up @@ -130,7 +133,7 @@ button:enabled:active {
background-color: orange;
}
.row > .loadState.ready {
background-color: #4CAF50;
background-color: #5cb35f;
}

.row > .output {
Expand Down

0 comments on commit bb3216d

Please sign in to comment.