Skip to content

Commit c12ff77

Browse files
committed
fix: full esm support
1 parent 7d2b9b6 commit c12ff77

File tree

4 files changed

+69
-89
lines changed

4 files changed

+69
-89
lines changed

.gitignore

+17-73
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,24 @@
1-
# Windows image file caches
2-
Thumbs.db
3-
ehthumbs.db
4-
5-
# Folder config file
6-
Desktop.ini
7-
8-
# Recycle Bin used on file shares
9-
$RECYCLE.BIN/
10-
11-
# Windows Installer files
12-
*.cab
13-
*.msi
14-
*.msm
15-
*.msp
16-
17-
# Windows shortcuts
18-
*.lnk
19-
20-
# =========================
21-
# Operating System Files
22-
# =========================
23-
24-
# OSX
25-
# =========================
26-
27-
.DS_Store
28-
.AppleDouble
29-
.LSOverride
301
.idea
31-
32-
# Thumbnails
33-
._*
34-
35-
# Files that might appear on external disk
36-
.Spotlight-V100
37-
.Trashes
38-
39-
# Directories potentially created on remote AFP share
40-
.AppleDB
41-
.AppleDesktop
42-
Network Trash Folder
43-
Temporary Items
44-
.apdisk
45-
46-
bin
47-
obj
48-
build
49-
.vs
50-
.tscache
51-
*.user
52-
*.js
53-
*.map
54-
!gruntfile.js
2+
.vscode
553
node_modules
56-
*.tmp.*
574
platforms
58-
lib
59-
*.css
60-
!webpack.*.js
61-
report
62-
*.log
63-
5+
hooks
6+
package-lock.json
7+
.DS_Store
8+
npm-debug.log.*
9+
demo*/app/**/*.js
10+
demo*/typings
6411
*.framework
65-
*.aar
66-
12+
**/*.js.map
13+
src/**/*.js
14+
plugin/**/*.js
15+
plugin/**/*.d.ts
16+
bin
17+
build
6718
Pods
68-
*.lock
69-
*.xcworkspace
70-
*.framework/
71-
*.tgz
72-
73-
/plugin/**/*.d.ts
7419
!plugin/platforms
75-
*.aar*
76-
/plugin/package-lock.json
77-
plugin/**/*.d.ts
78-
/schema
79-
pnpm-lock.yaml
20+
/plugin/platforms/android/*.aar
21+
*.xcuserdatad
8022
/plugin/README.md
23+
plugin/**/*js.map
24+
plugin/**/*js

build.esm.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const copy = require('recursive-copy');
2+
const through = require('through2');
3+
4+
const options = {
5+
overwrite: true,
6+
expand: true,
7+
dot: true,
8+
junk: true,
9+
filter: ['**/*'],
10+
rename (filePath) {
11+
return filePath.replace(/(.*)\.js(\.map)?$/, '$1.mjs$2');
12+
},
13+
transform (src, dest, stats) {
14+
return through(function (chunk, enc, done) {
15+
const output = chunk.toString().replace(/((?:(?:"file":")| sourceMappingURL=).*)\.js(\.map)?/g, '$1.mjs$2');
16+
done(null, output);
17+
});
18+
},
19+
};
20+
21+
copy('build/esm', 'plugin', options)
22+
// .on(copy.events.COPY_FILE_START, function (copyOperation) {
23+
// console.info('Copying file ' + copyOperation.src + '...');
24+
// })
25+
.on(copy.events.COPY_FILE_COMPLETE, function (copyOperation) {
26+
console.info('Copied to ' + copyOperation.dest);
27+
})
28+
.on(copy.events.ERROR, function (error, copyOperation) {
29+
console.error('Unable to copy ' + copyOperation.dest);
30+
})
31+
.then(function (results) {
32+
console.info(results.length + ' file(s) copied');
33+
})
34+
.catch(function (error) {
35+
return console.error('Copy failed: ' + error);
36+
});

package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"version": "1.0.0",
44
"description": "Nativescript plugin for Charts",
55
"scripts": {
6-
"tsc": "tsc -skipLibCheck",
6+
"tsc": "tsc -skipLibCheck -d",
77
"clean": "rimraf ./plugin/**/*.d.ts ./plugin/**/*.js ./plugin/**/*.js.map plugin/node_modules plugin/package-lock.json",
8-
"build.plugin": "pnpm i && npm run tsc && cp README.md plugin/",
9-
"build": "cp README.md plugin/ && npm run tsc",
8+
"build.esm": "tsc -skipLibCheck --target es2015 --removeComments --outDir build/esm",
9+
"build": "cp README.md plugin/ && rm -f .tsbuildinfo && npm run tsc && npm run build.esm && node ./build.esm.js",
1010
"demo.ios": "npm i && npm run tsc && cd demo && tns run ios",
1111
"demo.android": "npm i && npm run tsc && cd demo && tns run android",
1212
"clean.demo": "rimraf demo/hooks demo/node_modules demo/platforms",
@@ -48,7 +48,9 @@
4848
"npm-watch": "^0.6.0",
4949
"number-format.js": "^2.0.9",
5050
"prompt": "^1.0.0",
51-
"rimraf": "^3.0.0",
51+
"recursive-copy": "^2.0.10",
52+
"rimraf": "^3.0.2",
53+
"through2": "^3.0.1",
5254
"tns-platform-declarations": "^6.3.2",
5355
"tslint": "^5.20.1",
5456
"tslint-config-prettier": "^1.18.0",

tsconfig.json

+10-12
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
"target": "es5",
44
"module": "commonjs",
55
"moduleResolution": "node",
6-
"declaration": true,
7-
"removeComments": false,
6+
"removeComments": true,
87
"noLib": false,
9-
"emitDecoratorMetadata": true,
8+
"emitDecoratorMetadata": false,
109
"experimentalDecorators": true,
1110
"lib": ["es6", "dom"],
1211
"sourceMap": true,
@@ -17,22 +16,21 @@
1716
"noEmitOnError": false,
1817
"noImplicitAny": false,
1918
"noImplicitReturns": true,
20-
"noImplicitUseStrict": false,
19+
"noImplicitUseStrict": true,
2120
"noFallthroughCasesInSwitch": true,
21+
"sourceRoot": "../src",
2222
"baseUrl": ".",
2323
"outDir": "./plugin",
24-
"rootDir": "./src/charting",
2524
"paths": {
26-
27-
"tns-core-modules": ["node_modules/@nativescript/core"],
28-
"tns-core-modules/*": ["node_modules/@nativescript/core/*"],
29-
"nativescript-chart": ["./src/charting"],
30-
"nativescript-chart/*": ["./src/charting/*"],
25+
"tns-core-modules": ["./node_modules/@nativescript/core"],
26+
"tns-core-modules/*": ["./node_modules/@nativescript/core/*"],
27+
"nativescript-chart": ["src/charting"],
28+
"nativescript-chart/*": ["src/charting/*"],
3129
"*": ["node_modules/*"]
3230
}
3331
},
34-
"include": ["src/**/*.ts", "./references.d.ts", "./src/references.d.ts"],
35-
"exclude": ["platforms"],
32+
"include": ["src/**/*", "./references.d.ts"],
33+
"exclude": ["node_modules", "platforms"],
3634
"compileOnSave": false,
3735
"angularCompilerOptions": {
3836
"skipTemplateCodegen": true

0 commit comments

Comments
 (0)