diff --git a/.babelrc b/babelrc.cjs.json similarity index 85% rename from .babelrc rename to babelrc.cjs.json index 77b4e0b9..1638d2a7 100644 --- a/.babelrc +++ b/babelrc.cjs.json @@ -5,7 +5,7 @@ "@babel/preset-env", { "targets": { - "node": "10" + "node": "12" } } ] diff --git a/babelrc.esm.json b/babelrc.esm.json new file mode 100644 index 00000000..cca569ea --- /dev/null +++ b/babelrc.esm.json @@ -0,0 +1,14 @@ +{ + "presets": [ + "@babel/preset-flow", + [ + "@babel/preset-env", + { + "targets": { + "node": "12" + }, + "modules": false + } + ] + ] +} diff --git a/package.json b/package.json index 292ecded..9f602cb5 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "@parcel/source-map", "version": "2.1.0", "main": "./dist/node.js", + "module": "./dist/node.mjs", "types": "index.d.ts", "license": "MIT", "repository": { @@ -15,7 +16,9 @@ "benchmark": "node ./bench/run", "benchmark:node": "cross-env BACKEND=node yarn benchmark", "benchmark:wasm": "cross-env BACKEND=wasm yarn benchmark", - "transpile": "babel ./src/*.js --out-dir ./dist && flow-copy-source -v src dist", + "transpile:cjs": "babel ./src/*.js --out-dir ./dist --config-file ./babelrc.cjs.json", + "transpile:esm": "babel ./src/*.js --out-dir ./dist --out-file-extension .mjs --config-file ./babelrc.esm.json", + "transpile": "yarn transpile:cjs && yarn transpile:esm && flow-copy-source -v src dist", "build:clean": "cd ./parcel_sourcemap_node && rm -rf artifacts && mkdir artifacts", "build:node": "yarn build:clean && node parcel_sourcemap_node/build.js", "build:node-release": "yarn build:clean && node parcel_sourcemap_node/build.js --release",