fix(build): publish Node (server) friendly bundles (#3483)
Co-authored-by: Daniel Sogl <mytechde@outlook.com>
This commit is contained in:
parent
0932e113b2
commit
b4227f2114
9
package-lock.json
generated
9
package-lock.json
generated
@ -12924,6 +12924,15 @@
|
||||
"inherits": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"rollup": {
|
||||
"version": "2.18.2",
|
||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.18.2.tgz",
|
||||
"integrity": "sha512-+mzyZhL9ZyLB3eHBISxRNTep9Z2qCuwXzAYkUbFyz7yNKaKH03MFKeiGOS1nv2uvPgDb4ASKv+FiS5mC4h5IFQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"fsevents": "~2.1.2"
|
||||
}
|
||||
},
|
||||
"rsvp": {
|
||||
"version": "4.8.5",
|
||||
"resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz",
|
||||
|
@ -55,6 +55,7 @@
|
||||
"natives": "^1.1.6",
|
||||
"prettier": "^2.2.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "^2.18.2",
|
||||
"rxjs": "~6.6.0",
|
||||
"ts-jest": "^26.4.4",
|
||||
"ts-node": "~8.3.0",
|
||||
|
@ -2,6 +2,7 @@ import * as ts from 'typescript';
|
||||
import * as fs from 'fs-extra';
|
||||
import * as path from 'path';
|
||||
import * as rimraf from 'rimraf';
|
||||
import * as rollup from 'rollup';
|
||||
import { generateDeclarations } from './transpile';
|
||||
import { clone } from 'lodash';
|
||||
import { EmitFlags, createCompilerHost, CompilerOptions, CompilerHost, createProgram } from '@angular/compiler-cli';
|
||||
@ -54,6 +55,31 @@ export function generateDeclarationFiles() {
|
||||
generateDeclarations(PLUGIN_PATHS.map(p => p.replace('index.ts', 'ngx/index.ts')));
|
||||
}
|
||||
|
||||
export function generateLegacyBundles() {
|
||||
[
|
||||
path.resolve(ROOT, 'dist/@ionic-native/core/index.js'),
|
||||
...PLUGIN_PATHS.map(p =>
|
||||
p.replace(path.join(ROOT, 'src'), path.join(ROOT, 'dist')).replace('index.ts', 'ngx/index.js')
|
||||
),
|
||||
].forEach(p =>
|
||||
rollup
|
||||
.rollup({
|
||||
input: p,
|
||||
onwarn(warning, warn) {
|
||||
if (warning.code === 'UNUSED_EXTERNAL_IMPORT') return;
|
||||
warn(warning);
|
||||
},
|
||||
external: ['@angular/core', '@ionic-native/core', 'rxjs', 'tslib'],
|
||||
})
|
||||
.then(bundle =>
|
||||
bundle.write({
|
||||
file: path.join(path.dirname(p), 'bundle.js'),
|
||||
format: 'cjs',
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// remove reference to @ionic-native/core decorators
|
||||
export function modifyMetadata() {
|
||||
debugger;
|
||||
|
@ -1,7 +1,15 @@
|
||||
import { cleanupNgx, generateDeclarationFiles, modifyMetadata, transpileNgx, transpileNgxCore } from '../build/ngx';
|
||||
import {
|
||||
cleanupNgx,
|
||||
generateLegacyBundles,
|
||||
generateDeclarationFiles,
|
||||
modifyMetadata,
|
||||
transpileNgx,
|
||||
transpileNgxCore,
|
||||
} from '../build/ngx';
|
||||
|
||||
transpileNgxCore();
|
||||
transpileNgx();
|
||||
generateLegacyBundles();
|
||||
generateDeclarationFiles();
|
||||
modifyMetadata();
|
||||
cleanupNgx();
|
||||
|
@ -15,6 +15,7 @@ const FLAGS = '--access public';
|
||||
|
||||
const PACKAGE_JSON_BASE = {
|
||||
description: 'Ionic Native - Native plugins for ionic apps',
|
||||
main: 'bundle.js',
|
||||
module: 'index.js',
|
||||
typings: 'index.d.ts',
|
||||
author: 'ionic',
|
||||
|
Loading…
Reference in New Issue
Block a user