Skip to content

Commit

Permalink
feat: Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
mpeyper committed Mar 11, 2021
1 parent 2ef5109 commit 2aae392
Show file tree
Hide file tree
Showing 18 changed files with 131 additions and 103 deletions.
8 changes: 4 additions & 4 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
printWidth: 100,
semi: false,
singleQuote: true,
arrowParens: "always",
proseWrap: "always",
trailingComma: "none",
};
arrowParens: 'always',
proseWrap: 'always',
trailingComma: 'none'
}
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Please make sure to run the tests before you commit your changes. You can do so

## Help needed

Please check out the
[the open issues](https://github.com/OpenSourceRaidGuild/babel-vite/issues).
Please check out the [the open issues](https://github.com/OpenSourceRaidGuild/babel-vite/issues).

Also, please watch the repo and respond to questions/bug reports/feature requests! Thanks!
25 changes: 11 additions & 14 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@ MIT License

Copyright (c) [2021] [Michael Peyper]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This repo includes the following presets and plugins:
- [babel-plugin-transform-vite-meta-env](./packages/babel-plugin-transform-vite-meta-env)
- [babel-plugin-transform-vite-meta-glob](./packages/babel-plugin-transform-vite-meta-glob)

For installation, usage and example, please refer to the documentation in the above packages.
For installation, usage and example, please refer to the documentation in the above packages.

## Contributors ✨

Expand All @@ -35,7 +35,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors)
specification. Contributions of any kind welcome!

## Issues

Expand All @@ -59,8 +60,8 @@ maintainers prioritize what to work on.
### ❓ Questions

For questions related to using the library, you can
[raise issue here](https://github.com/OpenSourceRaidGuild/babel-vite/issues/new), or
visit a support community:
[raise issue here](https://github.com/OpenSourceRaidGuild/babel-vite/issues/new), or visit a support
community:

- [Discord](https://discord.gg/grS89HWeYh)
- [Stack Overflow](https://stackoverflow.com/questions/tagged/babeljs+or+vitejs+or+babel-vite)
Expand Down
6 changes: 0 additions & 6 deletions lerna.json

This file was deleted.

55 changes: 42 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
{
"name": "babel-vite",
"description": "babel preset and plugins that emulate vite's non-standard functionality",
"scripts": {
"setup": "npm install && npm run validate -s",
"postinstall": "lerna bootstrap",
"validate": "kcd-scripts validate",
"prepare": "npm run build",
"build": "lerna run build",
"test": "lerna run test -- -- --coverage",
"typecheck": "kcd-scripts typecheck",
"lint": "kcd-scripts lint",
"format": "kcd-scripts format",
"coverage": "codecov"
},
"repository": {
"type": "git",
"url": "git+https://github.com/OpenSourceRaidGuild/babel-vite.git"
Expand All @@ -29,9 +17,50 @@
"url": "https://github.com/OpenSourceRaidGuild/babel-vite/issues"
},
"homepage": "https://github.com/OpenSourceRaidGuild/babel-vite#readme",
"workspaces": [
"packages/*"
],
"lint-staged": {
"*.+(js|jsx|json|ts|tsx|md)": [
"npm run format",
"npm run lint",
"npm run test"
]
},
"release": {
"branches": [
"main",
{
"name": "alpha",
"prerelease": true
},
{
"name": "beta",
"prerelease": true
}
]
},
"scripts": {
"setup": "npm install && npm run validate -s",
"postinstall": "npm run build",
"validate": "kcd-scripts validate",
"prepare": "npm run build",
"build": "run-p --aggregate-output build:**",
"build:babel-plugin-transform-vite-meta-env": "npm run build --prefix packages/babel-plugin-transform-vite-meta-env",
"build:babel-plugin-transform-vite-meta-glob": "npm run build --prefix packages/babel-plugin-transform-vite-meta-glob",
"build:babel-preset-vite": "npm run build --prefix packages/babel-preset-vite",
"test": "run-p --aggregate-output test:** --",
"test:babel-plugin-transform-vite-meta-env": "npm run test --prefix packages/babel-plugin-transform-vite-meta-env -- --coverage",
"test:babel-plugin-transform-vite-meta-glob": "npm run test --prefix packages/babel-plugin-transform-vite-meta-glob -- --coverage",
"test:babel-preset-vite": "npm run test --prefix packages/babel-preset-vite -- --coverage",
"typecheck": "kcd-scripts typecheck",
"lint": "kcd-scripts lint",
"format": "kcd-scripts format"
},
"devDependencies": {
"kcd-scripts": "^8.0.2",
"lerna": "^4.0.0",
"multi-semantic-release": "^2.8.0",
"npm-run-all": "^4.1.5",
"typescript": "^4.2.2",
"vite": "^2.0.5"
}
Expand Down
6 changes: 3 additions & 3 deletions packages/babel-plugin-transform-vite-meta-env/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ babel --plugins babel-plugin-transform-vite-meta-env script.js
### Via Node API

```javascript
require("@babel/core").transformSync("code", {
plugins: ["babel-plugin-transform-vite-meta-env"]
});
require('@babel/core').transformSync('code', {
plugins: ['babel-plugin-transform-vite-meta-env']
})
```
10 changes: 5 additions & 5 deletions packages/babel-plugin-transform-vite-meta-env/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
{
"name": "babel-plugin-transform-vite-meta-env",
"version": "1.0.0",
"version": "0.0.0-semantically-released",
"description": "babel plugin that emulates vite's import.meta.env functionality",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"files": [
"lib",
"src"
],
"scripts": {
"build": "kcd-scripts build --out-dir lib",
"test": "kcd-scripts test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/OpenSourceRaidGuild/babel-vite.git"
Expand All @@ -30,6 +26,10 @@
"url": "https://github.com/OpenSourceRaidGuild/babel-vite/issues"
},
"homepage": "https://github.com/OpenSourceRaidGuild/babel-vite#readme",
"scripts": {
"build": "kcd-scripts build --out-dir lib",
"test": "kcd-scripts test"
},
"devDependencies": {
"@babel/core": "^7.13.8",
"@types/babel-plugin-tester": "^9.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import pluginTester from 'babel-plugin-tester'
import plugin from '..'

pluginTester({
plugin,
pluginName: 'vite-meta-env',
snapshot: true,
tests: {
'replace MODE': 'const x = import.meta.env.MODE',
'replace BASE_URL': 'const x = import.meta.env.BASE_URL',
'replace NODE_ENV': 'const x = import.meta.env.NODE_ENV',
'replace DEV': 'const x = import.meta.env.DEV',
'replace PROD': 'const x = import.meta.env.PROD',
'replace VITE_* variables': 'const x = import.meta.env.VITE_VAR',
'not replaceable': 'const x = import.meta.env.OTHER',
'not import.meta.env': 'const x = process.env.MODE'
}
plugin,
pluginName: 'vite-meta-env',
snapshot: true,
tests: {
'replace MODE': 'const x = import.meta.env.MODE',
'replace BASE_URL': 'const x = import.meta.env.BASE_URL',
'replace NODE_ENV': 'const x = import.meta.env.NODE_ENV',
'replace DEV': 'const x = import.meta.env.DEV',
'replace PROD': 'const x = import.meta.env.PROD',
'replace VITE_* variables': 'const x = import.meta.env.VITE_VAR',
'not replaceable': 'const x = import.meta.env.OTHER',
'not import.meta.env': 'const x = process.env.MODE'
}
})
3 changes: 1 addition & 2 deletions packages/babel-plugin-transform-vite-meta-env/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ const REPLACE_VARS = [
},
{
regex: /^BASE_URL$/,
replacement: (template: typeof babelCore.template) =>
template.expression.ast("'/'")
replacement: (template: typeof babelCore.template) => template.expression.ast("'/'")
},
{
regex: /^DEV$/,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"],
"include": ["src/**/*"]
}
10 changes: 5 additions & 5 deletions packages/babel-plugin-transform-vite-meta-glob/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
{
"name": "babel-plugin-transform-vite-meta-glob",
"version": "1.0.0",
"version": "0.0.0-semantically-released",
"description": "babel plugin that emulates vite's import.meta.glob import.meta.globEager functionality",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"files": [
"lib",
"src"
],
"scripts": {
"build": "kcd-scripts build --out-dir lib",
"test": "kcd-scripts test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/OpenSourceRaidGuild/babel-vite.git"
Expand All @@ -31,6 +27,10 @@
"url": "https://github.com/OpenSourceRaidGuild/babel-vite/issues"
},
"homepage": "https://github.com/OpenSourceRaidGuild/babel-vite#readme",
"scripts": {
"build": "kcd-scripts build --out-dir lib",
"test": "kcd-scripts test"
},
"devDependencies": {
"@babel/core": "^7.13.8",
"@types/babel-plugin-tester": "^9.0.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`vite-meta-env glob all files eagerly: glob all files eagerly 1`] = `
exports[`vite-meta-glob glob all files eagerly: glob all files eagerly 1`] = `
const modules = import.meta.globEager("./fixtures/**/*")
Expand All @@ -15,7 +15,7 @@ const modules = {
`;

exports[`vite-meta-env glob all files: glob all files 1`] = `
exports[`vite-meta-glob glob all files: glob all files 1`] = `
const modules = import.meta.glob("./fixtures/**/*")
Expand All @@ -30,7 +30,7 @@ const modules = {
`;

exports[`vite-meta-env glob no files eagerly: glob no files eagerly 1`] = `
exports[`vite-meta-glob glob no files eagerly: glob no files eagerly 1`] = `
const modules = import.meta.globEager("./fixtures/**/not-found")
Expand All @@ -41,7 +41,7 @@ const modules = {}
`;

exports[`vite-meta-env glob no files: glob no files 1`] = `
exports[`vite-meta-glob glob no files: glob no files 1`] = `
const modules = import.meta.glob("./fixtures/**/not-found")
Expand All @@ -52,7 +52,7 @@ const modules = {}
`;

exports[`vite-meta-env glob some files eagerly: glob some files eagerly 1`] = `
exports[`vite-meta-glob glob some files eagerly: glob some files eagerly 1`] = `
const modules = import.meta.globEager("./fixtures/**/*{1,3}*")
Expand All @@ -66,7 +66,7 @@ const modules = {
`;

exports[`vite-meta-env glob some files: glob some files 1`] = `
exports[`vite-meta-glob glob some files: glob some files 1`] = `
const modules = import.meta.glob("./fixtures/**/*{1,3}*")
Expand All @@ -80,7 +80,7 @@ const modules = {
`;

exports[`vite-meta-env no filename: no filename 1`] = `
exports[`vite-meta-glob no filename: no filename 1`] = `
import.meta.glob("./fixtures/**/*")
Expand All @@ -91,7 +91,7 @@ import.meta.glob('./fixtures/**/*')
`;

exports[`vite-meta-env not a string arg: not a string arg 1`] = `
exports[`vite-meta-glob not a string arg: not a string arg 1`] = `
globEager(1)
Expand All @@ -102,7 +102,7 @@ globEager(1)
`;

exports[`vite-meta-env not import.meta function: not import.meta function 1`] = `
exports[`vite-meta-glob not import.meta function: not import.meta function 1`] = `
const x = import.meta.env
Expand All @@ -113,7 +113,7 @@ const x = import.meta.env
`;

exports[`vite-meta-env not import.meta.glob: not import.meta.glob 1`] = `
exports[`vite-meta-glob not import.meta.glob: not import.meta.glob 1`] = `
glob("./fixtures/**/*")
Expand All @@ -124,7 +124,7 @@ glob('./fixtures/**/*')
`;

exports[`vite-meta-env not import.meta.globEager: not import.meta.globEager 1`] = `
exports[`vite-meta-glob not import.meta.globEager: not import.meta.globEager 1`] = `
globEager("./fixtures/**/*")
Expand All @@ -135,7 +135,7 @@ globEager('./fixtures/**/*')
`;

exports[`vite-meta-env not import.meta: not import.meta 1`] = `
exports[`vite-meta-glob not import.meta: not import.meta 1`] = `
const x = import.meta.other()
Expand All @@ -146,7 +146,7 @@ const x = import.meta.other()
`;

exports[`vite-meta-env too many args: too many args 1`] = `
exports[`vite-meta-glob too many args: too many args 1`] = `
globEager("./fixtures/**/*1*", "./fixtures/**/*2*")
Expand Down
Loading

0 comments on commit 2aae392

Please sign in to comment.