blob: 5f7a831d0d95a685772312dc2e06bfff4de40f78 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/bin/bash
# The script generates the package in the given directory.
#
# It's addition to the build process. The script is used in examples.
# It also could be used to build date-fns from a git checkout.
set -e
# cd to the root dir
root="$(pwd)/$(dirname "$0")/../.."
cd "$root" || exit 1
PATH="$(npm bin):$PATH"
# XXX: $PACKAGE_OUTPUT_PATH must be an absolute path!
dir=${PACKAGE_OUTPUT_PATH:-"$root/tmp/package"}
# Clean up output dir
rm -rf "$dir"
mkdir -p "$dir"
# Traspile CommonJS versions of files
env BABEL_ENV='commonjs' babel src --source-root src --out-dir "$dir" --extensions .ts,.js --ignore test.js,benchmark.js,snapshot.md --copy-files --quiet
# Traspile ESM versions of files
env BABEL_ENV='esm' babel src --source-root src --out-dir "$dir/esm" --extensions .ts,.js --ignore test.js,benchmark.js,snapshot.md,package.json --copy-files --quiet
# Copy basic files
for pattern in CHANGELOG.md \
package.json \
docs \
LICENSE.md \
README.md \
typings.d.ts
do
cp -r "$pattern" "$dir"
done
# Remove clean up code when this issues is resolved:
# https://github.com/babel/babel/issues/6226
# Clean up dev code
find "$dir" -type f -name "test.js" -delete
find "$dir" -type f -name "benchmark.js" -delete
find "$dir" -type f -name "snapshot.md" -delete
# Clean up package.json pointing to the modules
find "$dir/esm" -type f -name "package.json" -delete
./scripts/build/packages.js
./scripts/build/removeOutdatedLocales.js $dir
|