Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Commit

Permalink
fix: switch to codegen.macro (#286)
Browse files Browse the repository at this point in the history
Honestly, this doesn't fix anything, but I want to push a release anyway... 🤷‍♂️
  • Loading branch information
Kent C. Dodds authored Aug 14, 2017
1 parent 250bcec commit 69dc3ad
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
14 changes: 9 additions & 5 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"presets": [
["env", {
"targets": {
"node": "4.5"
[
"env",
{
"targets": {
"node": "4.5"
}
}
}],
],
"stage-2",
"react"
]
],
"plugins": ["babel-macros"]
}
13 changes: 5 additions & 8 deletions other/concat-exports.js → other/get-exports-code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const appendToFile = require('fs').appendFileSync
const resolve = require('path').resolve
const htmlTagNames = require('html-tag-names')
const svgTagNames = require('svg-tag-names')

Expand Down Expand Up @@ -29,10 +27,9 @@ const componentExports = htmlTagNames
return `export var ${tagName} = glamorous['${capitalName}'];`
}).join`\n`

const introText =
'\n// these exports below are generated' +
"\n// and will be tree-shaken if you're using Webpack 2 or Rollup\n"
const introText = `
// these exports below are generated
// and will be tree-shaken if you're using Webpack 2 or Rollup
`

const glamorousEsFile = resolve(__dirname, '..', 'dist', 'glamorous.es.js')

appendToFile(glamorousEsFile, introText + componentExports)
module.exports = introText + componentExports
3 changes: 1 addition & 2 deletions package-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ module.exports = {
),
es: {
description: 'run the build with rollup (uses rollup.config.js)',
script:
'rollup --config --environment FORMAT:es && node other/concat-exports.js',
script: 'rollup --config --environment FORMAT:es',
tiny: 'rollup --config --environment FORMAT:es,TINY',
},
cjs: {
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@
"all-contributors-cli": "^4.3.0",
"babel-cli": "^6.24.1",
"babel-jest": "^20.0.3",
"babel-macros": "^0.5.2",
"babel-plugin-external-helpers": "^6.22.0",
"babel-preset-env": "^1.5.2",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"babel-register": "^6.24.1",
"bundlesize": "^0.12.2",
"codegen.macro": "^1.0.0",
"common-tags": "^1.4.0",
"cross-spawn": "^5.1.0",
"enzyme": "^2.8.2",
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default {
exclude: 'node_modules/**',
babelrc: false,
presets: [['env', {modules: false}], 'stage-2', 'react'],
plugins: ['external-helpers'],
plugins: ['external-helpers', 'babel-macros'],
}),
minify ? uglify() : null,
].filter(Boolean),
Expand Down
9 changes: 9 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import codegen from 'codegen.macro'
import domElements from './dom-elements'
import withTheme from './with-theme'
import ThemeProvider from './theme-provider'
Expand Down Expand Up @@ -59,3 +60,11 @@ glamorous.default = glamorous

export default glamorous
export {ThemeProvider, withTheme}

codegen`
if (process.env.FORMAT === 'es') {
module.exports = require('../other/get-exports-code')
} else {
module.exports = ''
}
`

0 comments on commit 69dc3ad

Please sign in to comment.