Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
cafb5ff8
Commit
cafb5ff8
authored
Sep 28, 2022
by
Tim Neutkens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Fix wasm"
This reverts commit
fbf1bd11
.
parent
62f996e5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
78 deletions
+68
-78
lib.rs
packages/next-swc/crates/wasm/src/lib.rs
+68
-78
No files found.
packages/next-swc/crates/wasm/src/lib.rs
View file @
cafb5ff8
...
@@ -8,9 +8,7 @@ use wasm_bindgen_futures::future_to_promise;
...
@@ -8,9 +8,7 @@ use wasm_bindgen_futures::future_to_promise;
use
swc_core
::{
use
swc_core
::{
base
::{
config
::
JsMinifyOptions
,
config
::
ParseOptions
,
try_with_handler
,
Compiler
},
base
::{
config
::
JsMinifyOptions
,
config
::
ParseOptions
,
try_with_handler
,
Compiler
},
common
::{
common
::{
comments
::
Comments
,
errors
::
ColorConfig
,
FileName
,
FilePathMapping
,
SourceMap
},
comments
::
Comments
,
errors
::
ColorConfig
,
FileName
,
FilePathMapping
,
SourceMap
,
GLOBALS
,
},
ecma
::
transforms
::
base
::
pass
::
noop
,
ecma
::
transforms
::
base
::
pass
::
noop
,
};
};
...
@@ -31,16 +29,14 @@ pub fn minify_sync(s: JsString, opts: JsValue) -> Result<JsValue, JsValue> {
...
@@ -31,16 +29,14 @@ pub fn minify_sync(s: JsString, opts: JsValue) -> Result<JsValue, JsValue> {
skip_filename
:
false
,
skip_filename
:
false
,
},
},
|
handler
|
{
|
handler
|
{
GLOBALS
.set
(
&
Default
::
default
(),
||
{
let
opts
:
JsMinifyOptions
=
opts
.into_serde
()
.context
(
"failed to parse options"
)
?
;
let
opts
:
JsMinifyOptions
=
opts
.into_serde
()
.context
(
"failed to parse options"
)
?
;
let
fm
=
c
.cm
.new_source_file
(
FileName
::
Anon
,
s
.into
());
let
fm
=
c
.cm
.new_source_file
(
FileName
::
Anon
,
s
.into
());
let
program
=
c
let
program
=
c
.minify
(
fm
,
handler
,
&
opts
)
.minify
(
fm
,
handler
,
&
opts
)
.context
(
"failed to minify file"
)
?
;
.context
(
"failed to minify file"
)
?
;
JsValue
::
from_serde
(
&
program
)
.context
(
"failed to serialize json"
)
JsValue
::
from_serde
(
&
program
)
.context
(
"failed to serialize json"
)
})
},
},
)
)
.map_err
(
convert_err
)
.map_err
(
convert_err
)
...
@@ -66,46 +62,43 @@ pub fn transform_sync(s: JsValue, opts: JsValue) -> Result<JsValue, JsValue> {
...
@@ -66,46 +62,43 @@ pub fn transform_sync(s: JsValue, opts: JsValue) -> Result<JsValue, JsValue> {
skip_filename
:
false
,
skip_filename
:
false
,
},
},
|
handler
|
{
|
handler
|
{
GLOBALS
.set
(
&
Default
::
default
(),
||
{
let
opts
:
TransformOptions
=
opts
.into_serde
()
.context
(
"failed to parse options"
)
?
;
let
opts
:
TransformOptions
=
opts
.into_serde
()
.context
(
"failed to parse options"
)
?
;
let
s
=
s
.dyn_into
::
<
js_sys
::
JsString
>
();
let
out
=
match
s
{
let
s
=
s
.dyn_into
::
<
js_sys
::
JsString
>
();
Ok
(
s
)
=>
{
let
out
=
match
s
{
let
fm
=
c
.cm
.new_source_file
(
Ok
(
s
)
=>
{
if
opts
.swc.filename
.is_empty
()
{
let
fm
=
c
.cm
.new_source_file
(
FileName
::
Anon
if
opts
.swc.filename
.is_empty
()
{
}
else
{
FileName
::
Anon
FileName
::
Real
(
opts
.swc.filename
.clone
()
.into
())
}
else
{
},
FileName
::
Real
(
opts
.swc.filename
.clone
()
.into
())
s
.into
(),
},
);
s
.into
(),
let
cm
=
c
.cm
.clone
();
);
let
file
=
fm
.clone
();
let
cm
=
c
.cm
.clone
();
c
.process_js_with_custom_pass
(
let
file
=
fm
.clone
();
fm
,
c
.process_js_with_custom_pass
(
None
,
fm
,
handler
,
None
,
&
opts
.swc
,
handler
,
|
_
,
comments
|
{
&
opts
.swc
,
custom_before_pass
(
|
_
,
comments
|
{
cm
,
custom_before_pass
(
file
,
cm
,
&
opts
,
file
,
comments
.clone
(),
&
opts
,
Default
::
default
(),
comments
.clone
(),
)
Default
::
default
(),
},
)
|
_
,
_
|
noop
(),
},
)
|
_
,
_
|
noop
(),
.context
(
"failed to process js file"
)
?
)
}
.context
(
"failed to process js file"
)
?
Err
(
v
)
=>
c
.process_js
(
handler
,
v
.into_serde
()
.expect
(
""
),
&
opts
.swc
)
?
,
}
};
Err
(
v
)
=>
c
.process_js
(
handler
,
v
.into_serde
()
.expect
(
""
),
&
opts
.swc
)
?
,
};
JsValue
::
from_serde
(
&
out
)
.context
(
"failed to serialize json"
)
JsValue
::
from_serde
(
&
out
)
.context
(
"failed to serialize json"
)
})
},
},
)
)
.map_err
(
convert_err
)
.map_err
(
convert_err
)
...
@@ -131,33 +124,30 @@ pub fn parse_sync(s: JsString, opts: JsValue) -> Result<JsValue, JsValue> {
...
@@ -131,33 +124,30 @@ pub fn parse_sync(s: JsString, opts: JsValue) -> Result<JsValue, JsValue> {
},
},
|
handler
|
{
|
handler
|
{
c
.run
(||
{
c
.run
(||
{
GLOBALS
.set
(
&
Default
::
default
(),
||
{
let
opts
:
ParseOptions
=
opts
.into_serde
()
.context
(
"failed to parse options"
)
?
;
let
opts
:
ParseOptions
=
opts
.into_serde
()
.context
(
"failed to parse options"
)
?
;
let
fm
=
c
.cm
.new_source_file
(
FileName
::
Anon
,
s
.into
());
let
fm
=
c
.cm
.new_source_file
(
FileName
::
Anon
,
s
.into
());
let
cmts
=
c
.comments
()
.clone
();
let
comments
=
if
opts
.comments
{
let
cmts
=
c
.comments
()
.clone
();
Some
(
&
cmts
as
&
dyn
Comments
)
let
comments
=
if
opts
.comments
{
}
else
{
Some
(
&
cmts
as
&
dyn
Comments
)
None
}
else
{
};
None
};
let
program
=
c
.parse_js
(
let
program
=
c
fm
,
.parse_js
(
handler
,
fm
,
opts
.target
,
handler
,
opts
.syntax
,
opts
.target
,
opts
.is_module
,
opts
.syntax
,
comments
,
opts
.is_module
,
)
comments
,
.context
(
"failed to parse code"
)
?
;
)
.context
(
"failed to parse code"
)
?
;
let
s
=
serde_json
::
to_string
(
&
program
)
.unwrap
();
Ok
(
JsValue
::
from_str
(
&
s
))
let
s
=
serde_json
::
to_string
(
&
program
)
.unwrap
();
Ok
(
JsValue
::
from_str
(
&
s
))
})
})
})
},
},
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment