Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(build): publish Node (server) friendly bundles #3483

Merged
merged 2 commits into from
Apr 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
26 changes: 26 additions & 0 deletions scripts/build/ngx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 9 additions & 1 deletion scripts/tasks/build-ngx.ts
Original file line number Diff line number Diff line change
@@ -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();
1 change: 1 addition & 0 deletions scripts/tasks/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down