Skip to content

Commit 662cd4f

Browse files
Merge pull request #455 from sql-formatter-org/esm
2 parents 493682e + 1ad0ce3 commit 662cd4f

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

.babelrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
2-
"presets": ["@babel/preset-env", "@babel/preset-typescript"],
2+
"presets": [["@babel/preset-env", { "modules": false }], "@babel/preset-typescript"],
33
"plugins": [
4-
"@babel/plugin-proposal-class-properties",
54
"add-module-exports",
65
[
76
"module-resolver",

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@
33
"version": "10.7.2",
44
"description": "Format whitespace in a SQL query to make it more readable",
55
"license": "MIT",
6-
"main": "lib/index.js",
6+
"main": "dist/sql-formatter.min.js",
7+
"module": "lib/index.js",
78
"types": "lib/src/index.d.ts",
9+
"exports": {
10+
".": "./lib/index.js"
11+
},
812
"bin": {
913
"sql-formatter": "./bin/sql-formatter-cli.js"
1014
},
15+
"type": "module",
16+
"sideEffects": false,
1117
"keywords": [
1218
"sql",
1319
"formatter",

webpack.common.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
const path = require('path');
1+
import path from 'path';
22

3-
module.exports = {
3+
export default {
44
entry: './src/index.ts',
55
output: {
6-
path: path.join(__dirname, 'dist'),
6+
path: path.resolve('./dist'),
77
filename: 'sql-formatter.js',
8-
library: 'sqlFormatter',
9-
libraryTarget: 'umd',
8+
library: { type: 'module' },
9+
module: true,
10+
},
11+
experiments: {
12+
outputModule: true,
1013
},
1114
resolve: {
1215
extensions: ['.js', '.ts'],
1316
alias: {
14-
src: path.resolve(__dirname, 'src/'),
17+
src: path.resolve('./src'),
1518
},
1619
},
1720
module: {

webpack.prod.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const merge = require('webpack-merge').merge;
2-
const common = require('./webpack.common.js');
1+
import { merge } from 'webpack-merge';
32

4-
module.exports = merge(common, {
3+
import common from './webpack.common.js';
4+
5+
export default merge(common, {
56
mode: 'production',
67
devtool: 'source-map',
78
output: {

0 commit comments

Comments
 (0)