johanholmerin / style9

CSS-in-JS compiler inspired by Meta's stylex
MIT License
570 stars 27 forks source link

feat: support `require('style9')` #89

Open SukkaW opened 1 year ago

SukkaW commented 1 year ago

Previously, style9 only supports import xxx from 'style9'. The PR adds support for const xxx = require('style9').

The unit test case is added in __tests__/code/import.js.

SukkaW commented 1 year ago

Seems that CI failed due to test coverage. Let me see what I can do.


Update

The test coverage reaches 100% and the CI is passed.

johanholmerin commented 1 year ago

The mutation testing report(available at the action run page) shows that more tests are needed for negative situations, i.e. code that shouldn't be processed.

Examples of situations that may need to be tested:

const style9 = require(style9);
let style9 = require('style9');
var style9 = require('style9');
const { create } = require('style9');
const style9 = foo.require('style9');
const create = require('style9').create;
const style9 = globalThis.require('style9');
require('style9')();
require('style9').create();
foo(require('style9'));
const style9 = require('style9', foo);
SukkaW commented 1 year ago
const style9 = require(style9);
let style9 = require('style9');
var style9 = require('style9');
const { create } = require('style9');
const style9 = foo.require('style9');
const create = require('style9').create;
const style9 = globalThis.require('style9');
require('style9')();
require('style9').create();
foo(require('style9'));
const style9 = require('style9', foo);

Sure, I will add the cases.


Added in johanholmerin/style9@80e3f9c (#89)

johanholmerin commented 1 year ago

The mutation tests are still lacking some coverage. The cases above were only examples, they may not be exactly what is required. Check the test report and you should be able to see what's needed.

johanholmerin commented 1 year ago

@SukkaW Is this PR still active?

SukkaW commented 1 year ago

I have been a bit busy recently. I will draft the PR for now.