Skip to content

Commit

Permalink
Transpile packages that contain browser code (#520)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcompiles authored Dec 2, 2021
1 parent 64791f3 commit b294764
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
12 changes: 12 additions & 0 deletions .changeset/old-phones-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@vanilla-extract/css': patch
'@vanilla-extract/dynamic': patch
'@vanilla-extract/private': patch
'@vanilla-extract/recipes': patch
'@vanilla-extract/sprinkles': patch
'@vanilla-extract/css-utils': patch
---

Transpile code to meet [esmodules target](https://babeljs.io/docs/en/babel-preset-env#targetsesmodules)

This should allow code that runs in the browser to conform to most browser policies. If you need to support browsers prior to the esmodules target (e.g. IE 11) then you'll need to configure custom transpilation in your projects.
10 changes: 3 additions & 7 deletions babel-jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
const baseConfig = require('./babel.config');

module.exports = {
...baseConfig,
plugins: [
...(baseConfig.plugins ?? []),
require.resolve('@vanilla-extract/babel-plugin'),
],
extends: './babel.config',
presets: [['@babel/preset-env', { targets: { node: 'current' } }]],
plugins: [require.resolve('@vanilla-extract/babel-plugin')],
};
18 changes: 14 additions & 4 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
module.exports = {
presets: [
'@babel/preset-typescript',
'@babel/preset-react',
['@babel/preset-env', { targets: { node: 12 } }],
presets: ['@babel/preset-typescript', '@babel/preset-react'],

overrides: [
{
include: [
'./packages/css',
'./packages/dynamic',
'./packages/private',
'./packages/recipes',
'./packages/sprinkles',
'./packages/utils',
],
presets: [['@babel/preset-env', { targets: { esmodules: true } }]],
},
],
};

0 comments on commit b294764

Please sign in to comment.