Skip to content

Commit

Permalink
chore: Add ES module build (#370)
Browse files Browse the repository at this point in the history
* chore: Add ES module build

* nit
  • Loading branch information
taion authored Mar 28, 2020
1 parent 5440842 commit 6161d33
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 52 deletions.
16 changes: 0 additions & 16 deletions .babelrc

This file was deleted.

18 changes: 18 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = (api) => ({
presets: [
[
'@4c',
{
targets: {},
modules: api.env() === 'esm' ? false : 'commonjs',
},
],
],
plugins: [api.env() !== 'esm' && 'add-module-exports'].filter(Boolean),

env: {
test: {
plugins: ['istanbul'],
},
},
});
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
!.babelrc.js
!.eslintrc.js

**/coverage/
**/lib/
**/es/
**/node_modules/
15 changes: 0 additions & 15 deletions .eslintrc

This file was deleted.

10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
extends: ['4catalyzer', 'prettier'],
plugins: ['prettier'],
env: {
browser: true,
},
rules: {
'prettier/prettier': 'error',
},
};
101 changes: 95 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,30 +1,119 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2

.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.pnp.*

# Transpiled code
# Transpiled code.
/lib
/es
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
"version": "0.10.0",
"description": "Pluggable browser scroll management",
"files": [
"lib"
"lib",
"es"
],
"main": "lib/index.js",
"module": "es/index.js",
"types": "lib/index.d.ts",
"scripts": {
"build": "babel src -d lib --delete-dir-on-start && cpy types/*.d.ts lib",
"build": "npm run build:cjs && npm run build:esm && npm run build:types",
"build:cjs": "babel -d lib --delete-dir-on-start src",
"build:esm": "babel --env-name esm -d es --delete-dir-on-start src",
"build:types": "cpy types/*.d.ts lib",
"format": "eslint --fix . && npm run prettier -- --write",
"lint": "eslint . && npm run prettier -- -l",
"prepublish": "npm run build",
Expand Down
13 changes: 0 additions & 13 deletions test/.eslintrc

This file was deleted.

16 changes: 16 additions & 0 deletions test/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
env: {
mocha: true,
},
globals: {
expect: false,
},
rules: {
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: true,
},
],
},
};

0 comments on commit 6161d33

Please sign in to comment.