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
fbf1bd11
Commit
fbf1bd11
authored
Sep 28, 2022
by
Donny/강동윤
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix wasm
parent
082e766e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
68 deletions
+78
-68
lib.rs
packages/next-swc/crates/wasm/src/lib.rs
+78
-68
No files found.
packages/next-swc/crates/wasm/src/lib.rs
View file @
fbf1bd11
...
@@ -8,7 +8,9 @@ use wasm_bindgen_futures::future_to_promise;
...
@@ -8,7 +8,9 @@ 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
::{
comments
::
Comments
,
errors
::
ColorConfig
,
FileName
,
FilePathMapping
,
SourceMap
},
common
::{
comments
::
Comments
,
errors
::
ColorConfig
,
FileName
,
FilePathMapping
,
SourceMap
,
GLOBALS
,
},
ecma
::
transforms
::
base
::
pass
::
noop
,
ecma
::
transforms
::
base
::
pass
::
noop
,
};
};
...
@@ -29,6 +31,7 @@ pub fn minify_sync(s: JsString, opts: JsValue) -> Result<JsValue, JsValue> {
...
@@ -29,6 +31,7 @@ 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
());
...
@@ -37,6 +40,7 @@ pub fn minify_sync(s: JsString, opts: JsValue) -> Result<JsValue, JsValue> {
...
@@ -37,6 +40,7 @@ pub fn minify_sync(s: JsString, opts: JsValue) -> Result<JsValue, JsValue> {
.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
)
...
@@ -62,7 +66,9 @@ pub fn transform_sync(s: JsValue, opts: JsValue) -> Result<JsValue, JsValue> {
...
@@ -62,7 +66,9 @@ pub fn transform_sync(s: JsValue, opts: JsValue) -> Result<JsValue, JsValue> {
skip_filename
:
false
,
skip_filename
:
false
,
},
},
|
handler
|
{
|
handler
|
{
let
opts
:
TransformOptions
=
opts
.into_serde
()
.context
(
"failed to parse options"
)
?
;
GLOBALS
.set
(
&
Default
::
default
(),
||
{
let
opts
:
TransformOptions
=
opts
.into_serde
()
.context
(
"failed to parse options"
)
?
;
let
s
=
s
.dyn_into
::
<
js_sys
::
JsString
>
();
let
s
=
s
.dyn_into
::
<
js_sys
::
JsString
>
();
let
out
=
match
s
{
let
out
=
match
s
{
...
@@ -99,6 +105,7 @@ pub fn transform_sync(s: JsValue, opts: JsValue) -> Result<JsValue, JsValue> {
...
@@ -99,6 +105,7 @@ pub fn transform_sync(s: JsValue, opts: JsValue) -> Result<JsValue, JsValue> {
};
};
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
)
...
@@ -124,7 +131,9 @@ pub fn parse_sync(s: JsString, opts: JsValue) -> Result<JsValue, JsValue> {
...
@@ -124,7 +131,9 @@ pub fn parse_sync(s: JsString, opts: JsValue) -> Result<JsValue, JsValue> {
},
},
|
handler
|
{
|
handler
|
{
c
.run
(||
{
c
.run
(||
{
let
opts
:
ParseOptions
=
opts
.into_serde
()
.context
(
"failed to parse options"
)
?
;
GLOBALS
.set
(
&
Default
::
default
(),
||
{
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
());
...
@@ -149,6 +158,7 @@ pub fn parse_sync(s: JsString, opts: JsValue) -> Result<JsValue, JsValue> {
...
@@ -149,6 +158,7 @@ pub fn parse_sync(s: JsString, opts: JsValue) -> Result<JsValue, JsValue> {
let
s
=
serde_json
::
to_string
(
&
program
)
.unwrap
();
let
s
=
serde_json
::
to_string
(
&
program
)
.unwrap
();
Ok
(
JsValue
::
from_str
(
&
s
))
Ok
(
JsValue
::
from_str
(
&
s
))
})
})
})
},
},
)
)
.map_err
(
convert_err
)
.map_err
(
convert_err
)
...
...
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