Skip to content

Commit

Permalink
Use Node.js package exports
Browse files Browse the repository at this point in the history
  • Loading branch information
necolas committed Sep 26, 2024
1 parent 9049dc2 commit 1f8bc95
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 33 deletions.
4 changes: 2 additions & 2 deletions apps/examples/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

const stylexPlugin = require('@stylexjs/babel-plugin');
const rsdPlugin = require('react-strict-dom/babel');
const reactStrictPlugin = require('react-strict-dom/babel');

function getPlatform(caller) {
return caller && caller.platform;
Expand All @@ -30,7 +30,7 @@ module.exports = function (api) {
const plugins = [];

if (platform === 'web') {
plugins.push([rsdPlugin, { debug: true }]);
plugins.push([reactStrictPlugin, { debug: true }]);
plugins.push([
stylexPlugin,
{
Expand Down
2 changes: 1 addition & 1 deletion packages/react-strict-dom/babel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function createShortFilename(absolutePath, baseDir = process.cwd()) {

module.exports = function ({ types: t }, options = {}) {
const packageName = 'react-strict-dom';
const packageRuntime = 'react-strict-dom/dist/dom/runtime';
const packageRuntime = 'react-strict-dom/runtime';
const findImportDeclaration = (body, sourceValue) =>
body.filter(
(node) =>
Expand Down
10 changes: 0 additions & 10 deletions packages/react-strict-dom/index.js

This file was deleted.

10 changes: 0 additions & 10 deletions packages/react-strict-dom/native.js

This file was deleted.

12 changes: 9 additions & 3 deletions packages/react-strict-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
"name": "react-strict-dom",
"version": "0.0.27",
"description": "React Strict DOM",
"main": "./dist/dom/index.js",
"module": "./dist/dom/index.js",
"react-native": "./dist/native/index.js",
"exports": {
".": {
"react-native": "./dist/native/index.js",
"default": "./dist/dom/index.js"
},
"./babel": "./babel/index.js",
"./runtime": "./dist/dom/runtime.js",
"./package.json": "./package.json"
},
"sideEffects": false,
"files": [
"*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`react-strict-dom/babel [transform] <html.*> elements aliased imports 1`] = `
"import * as _stylex from "@stylexjs/stylex";
import { defaultStyles as _defaultStyles } from "react-strict-dom/dist/dom/runtime";
import { defaultStyles as _defaultStyles } from "react-strict-dom/runtime";
import { html as h } from 'react-strict-dom';
function App() {
return <div {..._stylex.props(_defaultStyles.div, styles.root)} />;
Expand All @@ -12,7 +12,7 @@ function App() {

exports[`react-strict-dom/babel [transform] <html.*> elements basic element 1`] = `
"import * as _stylex from "@stylexjs/stylex";
import { defaultStyles as _defaultStyles } from "react-strict-dom/dist/dom/runtime";
import { defaultStyles as _defaultStyles } from "react-strict-dom/runtime";
import { html } from 'react-strict-dom';
function App() {
return <div {..._stylex.props(_defaultStyles.div)} />;
Expand All @@ -22,7 +22,7 @@ function App() {

exports[`react-strict-dom/babel [transform] <html.*> elements debug mode 1`] = `
"import * as _stylex from "@stylexjs/stylex";
import { defaultStyles as _defaultStyles } from "react-strict-dom/dist/dom/runtime";
import { defaultStyles as _defaultStyles } from "react-strict-dom/runtime";
import { html as h } from 'react-strict-dom';
function App() {
return <div data-react-src="bar/baz.js:5" {..._stylex.props(_defaultStyles.div)} />;
Expand All @@ -32,7 +32,7 @@ function App() {

exports[`react-strict-dom/babel [transform] <html.*> elements other props 1`] = `
"import * as _stylex from "@stylexjs/stylex";
import { defaultStyles as _defaultStyles } from "react-strict-dom/dist/dom/runtime";
import { defaultStyles as _defaultStyles } from "react-strict-dom/runtime";
import { html } from 'react-strict-dom';
function App() {
return <div role="presentation" {..._stylex.props(_defaultStyles.div)}>
Expand All @@ -50,7 +50,7 @@ function App() {

exports[`react-strict-dom/babel [transform] <html.*> elements repeated imports 1`] = `
"import * as _stylex from "@stylexjs/stylex";
import { defaultStyles as _defaultStyles } from "react-strict-dom/dist/dom/runtime";
import { defaultStyles as _defaultStyles } from "react-strict-dom/runtime";
import { html } from 'react-strict-dom';
import { html as h } from 'react-strict-dom';
function App() {
Expand All @@ -63,7 +63,7 @@ function App() {

exports[`react-strict-dom/babel [transform] <html.*> elements styled elements: array 1`] = `
"import * as _stylex from "@stylexjs/stylex";
import { defaultStyles as _defaultStyles } from "react-strict-dom/dist/dom/runtime";
import { defaultStyles as _defaultStyles } from "react-strict-dom/runtime";
import { html } from 'react-strict-dom';
function App() {
return <div {..._stylex.props(_defaultStyles.div, styles.one, styles.two)} />;
Expand All @@ -73,7 +73,7 @@ function App() {

exports[`react-strict-dom/babel [transform] <html.*> elements styled elements: simple 1`] = `
"import * as _stylex from "@stylexjs/stylex";
import { defaultStyles as _defaultStyles } from "react-strict-dom/dist/dom/runtime";
import { defaultStyles as _defaultStyles } from "react-strict-dom/runtime";
import { html } from 'react-strict-dom';
function App() {
return <div {..._stylex.props(_defaultStyles.div, styles.one)} />;
Expand Down

0 comments on commit 1f8bc95

Please sign in to comment.