fix(nx): make distribution ivy-friendly
This commit is contained in:
parent
a5351c9d36
commit
f007ca9d17
@ -60,9 +60,7 @@ describe('app', () => {
|
||||
const tsconfigApp = JSON.parse(
|
||||
stripJsonComments(getFileContent(tree, 'apps/my-app/tsconfig.app.json'))
|
||||
);
|
||||
expect(tsconfigApp.compilerOptions.outDir).toEqual(
|
||||
'../../dist/out-tsc/apps/my-app'
|
||||
);
|
||||
expect(tsconfigApp.compilerOptions.outDir).toEqual('../../dist/out-tsc');
|
||||
expect(tsconfigApp.extends).toEqual('./tsconfig.json');
|
||||
|
||||
const tslintJson = JSON.parse(
|
||||
@ -76,9 +74,6 @@ describe('app', () => {
|
||||
getFileContent(tree, 'apps/my-app-e2e/tsconfig.e2e.json')
|
||||
)
|
||||
);
|
||||
// expect(tsconfigE2E.compilerOptions.outDir).toEqual(
|
||||
// '../../dist/out-tsc/apps/my-app-e2e'
|
||||
// );
|
||||
expect(tsconfigE2E.extends).toEqual('./tsconfig.json');
|
||||
});
|
||||
|
||||
@ -206,7 +201,7 @@ describe('app', () => {
|
||||
{
|
||||
path: 'apps/my-dir/my-app/tsconfig.app.json',
|
||||
lookupFn: json => json.compilerOptions.outDir,
|
||||
expectedValue: '../../../dist/out-tsc/apps/my-dir/my-app'
|
||||
expectedValue: '../../../dist/out-tsc'
|
||||
},
|
||||
{
|
||||
path: 'apps/my-dir/my-app-e2e/tsconfig.json',
|
||||
@ -335,7 +330,7 @@ describe('app', () => {
|
||||
);
|
||||
expect(tsconfigAppJson.exclude).toEqual(['src/test.ts', '**/*.spec.ts']);
|
||||
expect(tsconfigAppJson.compilerOptions.outDir).toEqual(
|
||||
'../../dist/out-tsc/apps/my-app'
|
||||
'../../dist/out-tsc'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@ -229,9 +229,7 @@ function updateProject(options: NormalizedSchema): Rule {
|
||||
extends: `./tsconfig.json`,
|
||||
compilerOptions: {
|
||||
...json.compilerOptions,
|
||||
outDir: `${offsetFromRoot(options.appProjectRoot)}dist/out-tsc/${
|
||||
options.appProjectRoot
|
||||
}`
|
||||
outDir: `${offsetFromRoot(options.appProjectRoot)}dist/out-tsc`
|
||||
},
|
||||
exclude:
|
||||
options.unitTestRunner === 'jest'
|
||||
@ -307,9 +305,7 @@ function updateE2eProject(options: NormalizedSchema): Rule {
|
||||
extends: `./tsconfig.json`,
|
||||
compilerOptions: {
|
||||
...json.compilerOptions,
|
||||
outDir: `${offsetFromRoot(options.e2eProjectRoot)}dist/out-tsc/${
|
||||
options.e2eProjectRoot
|
||||
}`
|
||||
outDir: `${offsetFromRoot(options.e2eProjectRoot)}dist/out-tsc`
|
||||
}
|
||||
};
|
||||
})
|
||||
@ -345,6 +341,7 @@ export default function(schema: Schema): Rule {
|
||||
skipTests: options.skipTests,
|
||||
style: options.style,
|
||||
viewEncapsulation: options.viewEncapsulation,
|
||||
enableIvy: options.enableIvy,
|
||||
routing: false,
|
||||
skipInstall: true,
|
||||
skipPackageJson: false
|
||||
|
||||
@ -8,6 +8,7 @@ export interface Schema {
|
||||
inlineTemplate?: boolean;
|
||||
viewEncapsulation?: 'Emulated' | 'Native' | 'None';
|
||||
routing?: boolean;
|
||||
enableIvy?: boolean;
|
||||
prefix?: string;
|
||||
style?: string;
|
||||
skipTests?: boolean;
|
||||
|
||||
@ -40,6 +40,11 @@
|
||||
"description": "Generates a routing module.",
|
||||
"default": false
|
||||
},
|
||||
"enablyIvy": {
|
||||
"description": "**EXPERIMENTAL** True to create a new app that uses the Ivy rendering engine.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"prefix": {
|
||||
"type": "string",
|
||||
"format": "html-selector",
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "<%= offsetFromRoot %>dist/out-tsc/<%= projectRoot %>",
|
||||
"outDir": "<%= offsetFromRoot %>dist/out-tsc",
|
||||
"types": ["jasmine", "node"]
|
||||
},
|
||||
"files": ["src/test.ts"],
|
||||
|
||||
@ -118,7 +118,7 @@ module.exports = function(config) {
|
||||
expect(tsConfig).toEqual({
|
||||
extends: './tsconfig.json',
|
||||
compilerOptions: {
|
||||
outDir: '../../dist/out-tsc/libs/lib1',
|
||||
outDir: '../../dist/out-tsc',
|
||||
types: ['jasmine', 'node']
|
||||
},
|
||||
files: ['src/test.ts'],
|
||||
@ -182,7 +182,7 @@ module.exports = function(config) {
|
||||
expect(tsConfig).toEqual({
|
||||
extends: './tsconfig.json',
|
||||
compilerOptions: {
|
||||
outDir: '../../dist/out-tsc/apps/app1',
|
||||
outDir: '../../dist/out-tsc',
|
||||
types: ['jasmine', 'node']
|
||||
},
|
||||
files: ['src/test.ts', 'src/polyfills.ts'],
|
||||
|
||||
@ -345,9 +345,7 @@ function updateProject(options: NormalizedSchema): Rule {
|
||||
extends: `./tsconfig.json`,
|
||||
compilerOptions: {
|
||||
...json.compilerOptions,
|
||||
outDir: `${offsetFromRoot(options.projectRoot)}dist/out-tsc/${
|
||||
options.projectRoot
|
||||
}`
|
||||
outDir: `${offsetFromRoot(options.projectRoot)}dist/out-tsc`
|
||||
}
|
||||
};
|
||||
}),
|
||||
|
||||
@ -101,9 +101,7 @@ describe('schematic:cypress-project', () => {
|
||||
);
|
||||
|
||||
expect(tsconfigJson.extends).toEqual('./tsconfig.json');
|
||||
expect(tsconfigJson.compilerOptions.outDir).toEqual(
|
||||
'../../dist/out-tsc/apps/my-app-e2e/src'
|
||||
);
|
||||
expect(tsconfigJson.compilerOptions.outDir).toEqual('../../dist/out-tsc');
|
||||
});
|
||||
|
||||
describe('nested', () => {
|
||||
@ -180,7 +178,7 @@ describe('schematic:cypress-project', () => {
|
||||
);
|
||||
|
||||
expect(tsconfigJson.compilerOptions.outDir).toEqual(
|
||||
'../../../dist/out-tsc/apps/my-dir/my-app-e2e/src'
|
||||
'../../../dist/out-tsc'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"sourceMap": false,
|
||||
"outDir": "<%= offsetFromRoot %>dist/out-tsc/<%= projectRoot %>/src"
|
||||
"outDir": "<%= offsetFromRoot %>dist/out-tsc"
|
||||
},
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "<%= offsetFromRoot %>dist/out-tsc/<%= projectRoot %>",
|
||||
"outDir": "<%= offsetFromRoot %>dist/out-tsc",
|
||||
"module": "commonjs",
|
||||
"types": ["jest", "node"]
|
||||
},<% if(setupFile !== 'none') { %>
|
||||
|
||||
@ -123,7 +123,7 @@ describe('jestProject', () => {
|
||||
extends: './tsconfig.json',
|
||||
compilerOptions: {
|
||||
module: 'commonjs',
|
||||
outDir: '../../dist/out-tsc/libs/lib1',
|
||||
outDir: '../../dist/out-tsc',
|
||||
types: ['jest', 'node']
|
||||
},
|
||||
files: ['src/test-setup.ts'],
|
||||
|
||||
@ -87,9 +87,7 @@ describe('app', () => {
|
||||
getFileContent(tree, 'apps/my-node-app/tsconfig.app.json')
|
||||
)
|
||||
);
|
||||
expect(tsconfigApp.compilerOptions.outDir).toEqual(
|
||||
'../../dist/out-tsc/apps/my-node-app'
|
||||
);
|
||||
expect(tsconfigApp.compilerOptions.outDir).toEqual('../../dist/out-tsc');
|
||||
expect(tsconfigApp.extends).toEqual('./tsconfig.json');
|
||||
|
||||
const tslintJson = JSON.parse(
|
||||
@ -162,7 +160,7 @@ describe('app', () => {
|
||||
{
|
||||
path: 'apps/my-dir/my-node-app/tsconfig.app.json',
|
||||
lookupFn: json => json.compilerOptions.outDir,
|
||||
expectedValue: '../../../dist/out-tsc/apps/my-dir/my-node-app'
|
||||
expectedValue: '../../../dist/out-tsc'
|
||||
},
|
||||
{
|
||||
path: 'apps/my-dir/my-node-app/tsconfig.app.json',
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "<%= offset %>dist/out-tsc/<%= root %>",
|
||||
"outDir": "<%= offset %>dist/out-tsc",
|
||||
"types": ["node"]
|
||||
},
|
||||
"exclude": ["**/*.spec.ts"],
|
||||
|
||||
@ -57,9 +57,7 @@ describe('app', () => {
|
||||
const tsconfigApp = JSON.parse(
|
||||
stripJsonComments(tree.readContent('apps/my-app/tsconfig.app.json'))
|
||||
);
|
||||
expect(tsconfigApp.compilerOptions.outDir).toEqual(
|
||||
'../../dist/out-tsc/apps/my-app'
|
||||
);
|
||||
expect(tsconfigApp.compilerOptions.outDir).toEqual('../../dist/out-tsc');
|
||||
expect(tsconfigApp.extends).toEqual('./tsconfig.json');
|
||||
|
||||
const tslintJson = JSON.parse(
|
||||
@ -71,9 +69,7 @@ describe('app', () => {
|
||||
const tsconfigE2E = JSON.parse(
|
||||
stripJsonComments(tree.readContent('apps/my-app-e2e/tsconfig.e2e.json'))
|
||||
);
|
||||
expect(tsconfigE2E.compilerOptions.outDir).toEqual(
|
||||
'../../dist/out-tsc/apps/my-app-e2e/src'
|
||||
);
|
||||
expect(tsconfigE2E.compilerOptions.outDir).toEqual('../../dist/out-tsc');
|
||||
expect(tsconfigE2E.extends).toEqual('./tsconfig.json');
|
||||
});
|
||||
});
|
||||
@ -148,7 +144,7 @@ describe('app', () => {
|
||||
{
|
||||
path: 'apps/my-dir/my-app/tsconfig.app.json',
|
||||
lookupFn: json => json.compilerOptions.outDir,
|
||||
expectedValue: '../../../dist/out-tsc/apps/my-dir/my-app'
|
||||
expectedValue: '../../../dist/out-tsc'
|
||||
},
|
||||
{
|
||||
path: 'apps/my-dir/my-app-e2e/tsconfig.json',
|
||||
@ -158,7 +154,7 @@ describe('app', () => {
|
||||
{
|
||||
path: 'apps/my-dir/my-app-e2e/tsconfig.e2e.json',
|
||||
lookupFn: json => json.compilerOptions.outDir,
|
||||
expectedValue: '../../../dist/out-tsc/apps/my-dir/my-app-e2e/src'
|
||||
expectedValue: '../../../dist/out-tsc'
|
||||
},
|
||||
{
|
||||
path: 'apps/my-dir/my-app/tslint.json',
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "<%= offsetFromRoot %>dist/out-tsc/<%= appProjectRoot %>",
|
||||
"outDir": "<%= offsetFromRoot %>dist/out-tsc",
|
||||
"types": []
|
||||
},
|
||||
"exclude": ["**/*.spec.ts"],
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "<%= offsetFromRoot %>dist/out-tsc/<%= projectRoot %>",
|
||||
"outDir": "<%= offsetFromRoot %>dist/out-tsc",
|
||||
"types": []
|
||||
},
|
||||
"exclude": ["**/*.spec.ts", "**/*.spec.tsx"],
|
||||
|
||||
@ -36,6 +36,24 @@ describe('Update 8-0-0', () => {
|
||||
initialTree
|
||||
)
|
||||
.toPromise();
|
||||
initialTree = await schematicRunner
|
||||
.callRule(
|
||||
updateJsonInTree('tsconfig.json', json => ({
|
||||
compilerOptions: {}
|
||||
})),
|
||||
initialTree
|
||||
)
|
||||
.toPromise();
|
||||
initialTree = await schematicRunner
|
||||
.callRule(
|
||||
updateJsonInTree('tsconfig.app.json', json => ({
|
||||
compilerOptions: {
|
||||
outDir: '../../dist/out-tsc/apps/blah'
|
||||
}
|
||||
})),
|
||||
initialTree
|
||||
)
|
||||
.toPromise();
|
||||
initialTree = await schematicRunner
|
||||
.callRule(
|
||||
updateJsonInTree('angular.json', json => ({
|
||||
@ -164,6 +182,20 @@ describe('Update 8-0-0', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('set root dir', () => {
|
||||
it('should set root dir and update out dirs', async () => {
|
||||
const tree = await schematicRunner
|
||||
.runSchematicAsync('update-8.0.0', {}, initialTree)
|
||||
.toPromise();
|
||||
const rootTsConfig = readJsonInTree(tree, 'tsconfig.json');
|
||||
expect(rootTsConfig.compilerOptions.rootDir).toEqual('.');
|
||||
|
||||
const appTsConfig = readJsonInTree(tree, 'tsconfig.app.json');
|
||||
console.log(appTsConfig);
|
||||
expect(appTsConfig.compilerOptions.outDir).toEqual('../../dist/out-tsc');
|
||||
});
|
||||
});
|
||||
|
||||
describe('jest config', () => {
|
||||
it('should have the plugin path migrated', async () => {
|
||||
initialTree.create(
|
||||
|
||||
@ -262,6 +262,33 @@ const updateDefaultCollection = (host: Tree) => {
|
||||
});
|
||||
};
|
||||
|
||||
const setRootDirAndUpdateOurDir = (host: Tree) => {
|
||||
host.visit(path => {
|
||||
if (!path.endsWith('.json')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const json = host.read(path).toString();
|
||||
const match = json.match(/"outDir"\s*:\s*"([^"]+)"/);
|
||||
if (match) {
|
||||
const outParts = match[1].split('out-tsc');
|
||||
if (outParts.length > 1) {
|
||||
const updatedJson = json.replace(
|
||||
/"outDir"\s*:\s*"([^"]+)"/,
|
||||
`"outDir": "${outParts[0]}out-tsc"`
|
||||
);
|
||||
host.overwrite(path, updatedJson);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
updateJsonInTree('tsconfig.json', json => {
|
||||
json.compilerOptions = json.compilerOptions || {};
|
||||
json.compilerOptions.rootDir = '.';
|
||||
return json;
|
||||
})(host, null);
|
||||
};
|
||||
|
||||
export const runAngularMigrations: Rule = (
|
||||
host: Tree,
|
||||
context: SchematicContext
|
||||
@ -314,6 +341,7 @@ export default function(): Rule {
|
||||
updateTslintRules,
|
||||
addDependencies(),
|
||||
updateDefaultCollection,
|
||||
setRootDirAndUpdateOurDir,
|
||||
formatFiles()
|
||||
]);
|
||||
}
|
||||
|
||||
@ -59,9 +59,7 @@ describe('app', () => {
|
||||
const tsconfigApp = JSON.parse(
|
||||
stripJsonComments(tree.readContent('apps/my-app/tsconfig.app.json'))
|
||||
);
|
||||
expect(tsconfigApp.compilerOptions.outDir).toEqual(
|
||||
'../../dist/out-tsc/apps/my-app'
|
||||
);
|
||||
expect(tsconfigApp.compilerOptions.outDir).toEqual('../../dist/out-tsc');
|
||||
expect(tsconfigApp.extends).toEqual('./tsconfig.json');
|
||||
|
||||
const tslintJson = JSON.parse(
|
||||
@ -73,9 +71,7 @@ describe('app', () => {
|
||||
const tsconfigE2E = JSON.parse(
|
||||
stripJsonComments(tree.readContent('apps/my-app-e2e/tsconfig.e2e.json'))
|
||||
);
|
||||
expect(tsconfigE2E.compilerOptions.outDir).toEqual(
|
||||
'../../dist/out-tsc/apps/my-app-e2e/src'
|
||||
);
|
||||
expect(tsconfigE2E.compilerOptions.outDir).toEqual('../../dist/out-tsc');
|
||||
expect(tsconfigE2E.extends).toEqual('./tsconfig.json');
|
||||
});
|
||||
});
|
||||
@ -150,7 +146,7 @@ describe('app', () => {
|
||||
{
|
||||
path: 'apps/my-dir/my-app/tsconfig.app.json',
|
||||
lookupFn: json => json.compilerOptions.outDir,
|
||||
expectedValue: '../../../dist/out-tsc/apps/my-dir/my-app'
|
||||
expectedValue: '../../../dist/out-tsc'
|
||||
},
|
||||
{
|
||||
path: 'apps/my-dir/my-app-e2e/tsconfig.json',
|
||||
@ -160,7 +156,7 @@ describe('app', () => {
|
||||
{
|
||||
path: 'apps/my-dir/my-app-e2e/tsconfig.e2e.json',
|
||||
lookupFn: json => json.compilerOptions.outDir,
|
||||
expectedValue: '../../../dist/out-tsc/apps/my-dir/my-app-e2e/src'
|
||||
expectedValue: '../../../dist/out-tsc'
|
||||
},
|
||||
{
|
||||
path: 'apps/my-dir/my-app/tslint.json',
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "<%= offsetFromRoot %>dist/out-tsc/<%= appProjectRoot %>",
|
||||
"outDir": "<%= offsetFromRoot %>dist/out-tsc",
|
||||
"types": []
|
||||
},
|
||||
"exclude": ["**/*.spec.ts"],
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "<%= offsetFromRoot %>dist/out-tsc/<%= projectRoot %>",
|
||||
"outDir": "<%= offsetFromRoot %>dist/out-tsc",
|
||||
"types": []
|
||||
},
|
||||
"exclude": ["**/*.spec.ts"],
|
||||
|
||||
@ -249,23 +249,17 @@ function updateTsConfigsJson(options: Schema) {
|
||||
const offset = '../../';
|
||||
updateJsonFile(app.architect.build.options.tsConfig, json => {
|
||||
json.extends = `${offset}tsconfig.json`;
|
||||
json.compilerOptions.outDir = `${offset}dist/out-tsc/apps/${
|
||||
options.name
|
||||
}`;
|
||||
json.compilerOptions.outDir = `${offset}dist/out-tsc`;
|
||||
});
|
||||
|
||||
updateJsonFile(app.architect.test.options.tsConfig, json => {
|
||||
json.extends = `${offset}tsconfig.json`;
|
||||
json.compilerOptions.outDir = `${offset}dist/out-tsc/apps/${
|
||||
options.name
|
||||
}`;
|
||||
json.compilerOptions.outDir = `${offset}dist/out-tsc`;
|
||||
});
|
||||
|
||||
if (app.architect.server) {
|
||||
updateJsonFile(app.architect.server.options.tsConfig, json => {
|
||||
json.compilerOptions.outDir = `${offset}dist/out-tsc/apps/${
|
||||
options.name
|
||||
}-server`;
|
||||
json.compilerOptions.outDir = `${offset}dist/out-tsc`;
|
||||
});
|
||||
}
|
||||
|
||||
@ -274,9 +268,7 @@ function updateTsConfigsJson(options: Schema) {
|
||||
json.extends = `${offsetFromRoot(e2eProject.root)}tsconfig.json`;
|
||||
json.compilerOptions = {
|
||||
...json.compilerOptions,
|
||||
outDir: `${offsetFromRoot(e2eProject.root)}dist/out-tsc/${
|
||||
e2eProject.root
|
||||
}`
|
||||
outDir: `${offsetFromRoot(e2eProject.root)}dist/out-tsc`
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
{
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"rootDir": ".",
|
||||
"sourceMap": true,
|
||||
"declaration": false,
|
||||
"moduleResolution": "node",
|
||||
|
||||
@ -14,6 +14,11 @@ echo "Compiling Typescript..."
|
||||
./node_modules/.bin/ngc
|
||||
echo "Compiled Typescript"
|
||||
|
||||
rm build/packages/angular/testing/nrwl-angular-testing.metadata.json
|
||||
rm build/packages/angular/testing/index.metadata.json
|
||||
rm build/packages/workspace/index.metadata.json
|
||||
rm build/packages/workspace/testing.metadata.json
|
||||
|
||||
#TODO This is a temporary hack until we can publish named umds
|
||||
sed -i.bak "s/define(\[/define('@nrwl\/angular',\[/" build/packages/angular/bundles/nrwl-angular.umd.js
|
||||
sed -i.bak "s/define(\[/define('@nrwl\/angular',\[/" build/packages/angular/bundles/nrwl-angular.umd.min.js
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user