File tree Expand file tree Collapse file tree 4 files changed +17
-16
lines changed Expand file tree Collapse file tree 4 files changed +17
-16
lines changed Original file line number Diff line number Diff line change @@ -81,16 +81,14 @@ Future<RenderResult> _renderAsync(RenderOptions options) async {
81
81
var file = options.file == null ? null : p.absolute (options.file);
82
82
CompileResult result;
83
83
84
- print (StackTrace .current);
85
-
86
84
if (isMainThread == true ) {
87
- print (p.current );
85
+ print ("Creating worker thread" );
88
86
final worker = Worker (p.current, WorkerOptions (workerData: {options}));
89
87
worker.on ('message' , (CompileResult msg) => result = msg);
90
88
worker.on ('error' , (JSError error) {
91
89
jsThrow (_wrapException (error));
92
90
});
93
- } else {
91
+ } else if (isMainThread == false ) {
94
92
if (options.data != null ) {
95
93
result = await compileStringAsync (options.data,
96
94
nodeImporter: _parseImporter (options, start),
@@ -115,7 +113,9 @@ Future<RenderResult> _renderAsync(RenderOptions options) async {
115
113
} else {
116
114
throw ArgumentError ("Either options.data or options.file must be set." );
117
115
}
118
- parentPort.postMessage (result);
116
+ parentPort? .postMessage (result);
117
+ } else {
118
+ throw UnsupportedError ("Failed to create worker thread." );
119
119
}
120
120
121
121
return _newRenderResult (options, result, start);
Original file line number Diff line number Diff line change 1
- // Copyright 2017 Google Inc. Use of this source code is governed by an
1
+ // Copyright 2018 Google Inc. Use of this source code is governed by an
2
2
// MIT-style license that can be found in the LICENSE file or at
3
3
// https://opensource.org/licenses/MIT.
4
- @JS ("workerThreads" )
5
- library worker_threads;
6
- //Import is failing here
7
-
8
4
import 'package:js/js.dart' ;
9
5
10
- @JS ()
11
- external WorkerThreads get workerThreads ;
6
+ @JS ("worker_threads" )
7
+ external WorkerThreads get worker_threads ;
12
8
13
- bool isMainThread = workerThreads .isMainThread;
14
- ParentPort parentPort = workerThreads .parentPort;
9
+ bool isMainThread = worker_threads ? .isMainThread;
10
+ ParentPort parentPort = worker_threads ? .parentPort;
15
11
16
12
@JS ()
17
13
abstract class WorkerThreads {
Original file line number Diff line number Diff line change 14
14
"url" : " https://github.com/nex3"
15
15
},
16
16
"engines" : {
17
- "node" : " >=12.14.1 "
17
+ "node" : " >=11.7.0 "
18
18
},
19
19
"dependencies" : {
20
20
"chokidar" : " >=2.0.0 <4.0.0"
Original file line number Diff line number Diff line change @@ -26,7 +26,12 @@ void main(List<String> args) {
26
26
pkg.chocolateyNuspec = _nuspec;
27
27
pkg.homebrewRepo = "sass/homebrew-sass" ;
28
28
pkg.homebrewFormula = "sass.rb" ;
29
- pkg.jsRequires = {"fs" : "fs" , "chokidar" : "chokidar" , "readline" : "readline" };
29
+ pkg.jsRequires = {
30
+ "fs" : "fs" ,
31
+ "chokidar" : "chokidar" ,
32
+ "readline" : "readline" ,
33
+ "workerThreads" : "worker_threads"
34
+ };
30
35
pkg.jsModuleMainLibrary = "lib/src/node.dart" ;
31
36
pkg.npmPackageJson =
32
37
json.decode (File ("package/package.json" ).readAsStringSync ())
You can’t perform that action at this time.
0 commit comments