Comments (20)
If just test, it doesn't seem to have much code to write a webpack loader.
const { transform } = require('swc')
module.exports = function(source) {
const callback = this.async();
new Promise(function() {
callback(null, transform(source).code);
})
};
work fine for me.
from swc.
@useafterfree Just a simple demo
https://github.com/muzea-demo/swc-loader
use yarn link or npm link
https://github.com/muzea-demo/swc-loader-demo
Then install swc-loader in this project, run make.js to generate the lodash entry file.
from swc.
Thank you very much for trying swc.
The es3::reserved_word
pass is not implemented yet, so I guess it's expected result.
I'll fix it after finishing jsx support.
from swc.
Fixed in version 0.1.0
from swc.
@muzea I implemented commonjs / umd module bundler.
You can use like
{
"module": {
"type": "commonjs"
}
}
See: https://swc-project.github.io/docs/configuring-swc#module
from swc.
@kdy1 Awesome.
Will swc add some real-world tests like v8?
from swc.
@muzea Definitely yes.
Note that currently swc already passes almost all tests copied from babel
from swc.
@muzea How did you compile lodash with swc? Can you post an example?
from swc.
@kdy1 Now I can run through the demo, very exciting work.
But the results here are very strange.
If entry file is ./src/lodash.js
, only the meaningless assignments are included in the packaged results, and there are a lot of blank lines inside.
If entry file is ./src/test.js
, result is
WARNING in ./src/test.js 2:12-18
"export 'default' (imported as 'lodash') was not found in './lodash'
Itβs convenient to see why it is?
from swc.
I guess ./src/test.js
resulted in error because es module transform is not implemented yet.
from swc.
@kdy1 Corresponding to babel, is it babel-plugin-transform-modules-commonjs?
from swc.
@muzea You are correct. I'll implement it soon.
from swc.
I could compile whole lodash with swc-cli. Is it okay to close the issue?
I used npx swc -d out *.js
from swc.
@kdy1 Transform a single file is no error, but I want to use it with webpack.
from swc.
@kdy1 swc-cli seems to be a bit problematic(0.0.3), the lib directory after the bundle is not in the npm package.
from swc.
@kdy1 nice, cli now work fine. Is there a configuration description of the transform?
from swc.
Currently it is documented only on index.d.ts
I'll add it to docs soon
See: https://swc-project.github.io/docs/configuring-swc#jsctransform
from swc.
@kdy1 I see this example. If I want to transform to cjs or es3, how do I configure it?
from swc.
Currently it's not possible. I will implement module passes soon
from swc.
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
from swc.
Related Issues (20)
- plugin resolve logic incorrect HOT 4
- Compress `hoist_props` removes needed property from object
- docs.rs build is failing since 0.20.0 HOT 1
- Unable to load schema from `https://json.schemastore.org/swcrc` HOT 1
- Segmentation fault when transpiling "if" statement with @swc/core version > 1.3.100 in deno inside Alpine Linux docker container HOT 1
- ReferenceError: cannot access 'class' before initialization HOT 1
- Add __copyProps to @swc/helpers HOT 1
- css @starting-style
- Aliases (paths) are incorrectly resolved HOT 1
- Minifier doesn't respect `toString` method in object when converting it to string value
- Minifier doesn't respect `valueOf` method in object when converting it to number value
- Minifier converts array to string value incorrectly when `void 0` is in array
- Minifier inlines hoisted `var` variable usage incorrectly
- Performance regression after v1.4.1-nightly-20240210.1 HOT 3
- Optimize a[n]; n++ inside loopings HOT 2
- `test_transform` should possibly use `parse_program` instead of `parse_module` HOT 1
- Minifier removes property in object incorrectly when circular reference exists
- Minifier evaluates `slice` call of array wrong
- Minifier evaluates `toString` of array containing 1-empty hole to invalid expression when `unsafe` is true
- Minifier should check type of assignment target before merging assignments
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swc.