Skip to content

Commit

Permalink
build: fix babel typescript compilation of abstract classes
Browse files Browse the repository at this point in the history
  • Loading branch information
ifiokjr committed Feb 7, 2019
1 parent 29dde9c commit fcfe418
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 86 deletions.
2 changes: 2 additions & 0 deletions @remirror/core-extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
},
"dependencies": {
"@remirror/core": "0.0.0",
"@types/prosemirror-history": "1.0.1",
"@types/prosemirror-model": "^1.7.0",
"@types/prosemirror-state": "^1.2.1",
"@types/prosemirror-view": "^1.3.0",
"prosemirror-history": "1.0.3",
"prosemirror-model": "^1.7.0",
"prosemirror-state": "^1.2.2",
"prosemirror-view": "^1.7.0"
Expand Down
39 changes: 1 addition & 38 deletions @remirror/core/.babelrc.js
Original file line number Diff line number Diff line change
@@ -1,38 +1 @@
const defaultConfig = require('../../support/babel/base.babel');

module.exports = {
...defaultConfig,
presets: [
[
'@babel/preset-env',
{
modules: false,
targets: {
node: '8',
},
},
],
'@babel/preset-typescript',
'@babel/preset-react',
],
plugins: [
// 'babel-plugin-styled-components',
...defaultConfig.plugins,
],
env: {
test: {
presets: [
[
'@babel/preset-env',
{
targets: {
node: '8',
},
},
],
'@babel/preset-typescript',
'@babel/preset-react',
],
},
},
};
module.exports = require('../../support/babel/base.babel');
16 changes: 16 additions & 0 deletions @remirror/core/src/__tests__/nodes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
import { Doc, Paragraph, Text } from '..';

// While these tests seem simple there is a reason for them.
//
// While using abstract classes in TypeScript if the code is compiled with TS the compiled properties are not
// added to the class definition. This means I can declare an abstract property on a base class and letter extend that class
// defining the class with a getter for that property without any issue.
// For some reason when using babel and the `@babel/preset-typescript` this was not the case.
// Getters defined in parent classes were being ignored as the value was being set to void.
// The solution has been to remove this preset and replace it with the plugin `@babel/plugin-transform-typescript`
// placed as the first plugin in the list.
//
// If the abstract class code is run through the Babel TS plugin first then it is handled properly..
// These tests are here as a flag, in case someone does changes the babel compile pipeline in a way that breaks things.

describe('nodes', () => {
test('doc', () => {
const doc = new Doc();
expect(doc.name).toBe('doc');
expect(doc.pluginKey).toContainEntry(['key', 'doc$']);
});

test('paragraph', () => {
const paragraph = new Paragraph();
expect(paragraph.name).toBe('paragraph');
expect(paragraph.pluginKey).toContainEntry(['key', 'paragraph$']);
});

test('text', () => {
const text = new Text();
expect(text.name).toBe('text');
expect(text.pluginKey).toContainEntry(['key', 'text$']);
});
});
4 changes: 3 additions & 1 deletion @remirror/core/src/nodes/doc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { NodeExtension } from '../node-extension';

export class Doc extends NodeExtension {
public readonly name = 'doc';
get name() {
return 'doc';
}

get schema() {
return {
Expand Down
4 changes: 3 additions & 1 deletion @remirror/core/src/nodes/paragraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { NodeExtension } from '../node-extension';
import { SchemaNodeTypeParams } from '../types';

export class Paragraph extends NodeExtension {
public readonly name = 'paragraph';
get name() {
return 'paragraph';
}

get schema() {
return {
Expand Down
4 changes: 3 additions & 1 deletion @remirror/core/src/nodes/text.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { NodeExtension } from '../node-extension';

export class Text extends NodeExtension {
public readonly name = 'text';
get name() {
return 'text';
}

get schema() {
return {
Expand Down
1 change: 0 additions & 1 deletion @remirror/react/.babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ module.exports = {
},
},
],
'@babel/preset-typescript',
],
plugins: [...defaultConfig.plugins],
};
2 changes: 0 additions & 2 deletions @remirror/remirror/.babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const defaultConfig = require('../../support/babel/base.babel');
module.exports = {
...defaultConfig,
presets: [
'@babel/preset-typescript',
'@babel/preset-react',
[
'@babel/preset-env',
Expand All @@ -18,7 +17,6 @@ module.exports = {
env: {
test: {
presets: [
'@babel/preset-typescript',
'@babel/preset-react',
[
'@babel/preset-env',
Expand Down
1 change: 0 additions & 1 deletion @remirror/renderer/.babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ module.exports = {
},
},
],
'@babel/preset-typescript',
],
plugins: [...defaultConfig.plugins],
};
2 changes: 1 addition & 1 deletion internal/dependencies/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"@babel/plugin-syntax-dynamic-import": "7.2.0",
"@babel/plugin-transform-react-jsx": "7.3.0",
"@babel/plugin-transform-runtime": "7.2.0",
"@babel/plugin-transform-typescript": "7.2.0",
"@babel/polyfill": "7.2.5",
"@babel/preset-env": "7.3.1",
"@babel/preset-react": "7.0.0",
"@babel/preset-typescript": "7.1.0",
"@storybook/addon-actions": "4.1.11",
"@storybook/addon-console": "1.1.0",
"@storybook/addon-links": "4.1.11",
Expand Down
3 changes: 1 addition & 2 deletions internal/dependencies/test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"stylelint": "9.10.1",
"stylelint-config-recommended": "2.1.0",
"stylelint-config-styled-components": "0.1.1",
"stylelint-processor-styled-components": "1.5.2",
"ts-jest": "23.10.5"
"stylelint-processor-styled-components": "1.5.2"
}
}
2 changes: 1 addition & 1 deletion support/babel/base.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ module.exports = {
},
},
],
'@babel/preset-typescript',
'@babel/preset-react',
],
plugins: [
'@babel/plugin-transform-typescript',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-syntax-dynamic-import',
Expand Down
74 changes: 37 additions & 37 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"

"@babel/plugin-transform-typescript@^7.1.0":
"@babel/plugin-transform-typescript@7.2.0", "@babel/plugin-transform-typescript@^7.1.0":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.2.0.tgz#bce7c06300434de6a860ae8acf6a442ef74a99d1"
integrity sha512-EnI7i2/gJ7ZNr2MuyvN2Hu+BHJENlxWte5XygPvfj/MbvtOkWor9zcnHpMMQL2YYaaCcqtIvJUyJ7QVfoGs7ew==
Expand Down Expand Up @@ -2741,6 +2741,14 @@
"@types/prosemirror-state" "*"
"@types/prosemirror-view" "*"

"@types/prosemirror-history@1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@types/prosemirror-history/-/prosemirror-history-1.0.1.tgz#b8d7595f73788b63fc9f2b57a763ba8375abfe87"
integrity sha512-BYyPJlWDo3VEnWS5X2DCHXrrAKEjdbCe1DUjGL6R/8hmwMFe3iMJGYdBkOXU1FfkTpw7Z+PlwY/pMyeelVydmg==
dependencies:
"@types/prosemirror-model" "*"
"@types/prosemirror-state" "*"

"@types/prosemirror-inputrules@^1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@types/prosemirror-inputrules/-/prosemirror-inputrules-1.0.2.tgz#60b946ca2782f0f453b65105e2ebfd1730324caa"
Expand Down Expand Up @@ -4481,13 +4489,6 @@ browserslist@^4.1.0, browserslist@^4.3.4, browserslist@^4.4.1:
electron-to-chromium "^1.3.103"
node-releases "^1.1.3"

bs-logger@0.x:
version "0.2.6"
resolved "https://registry.yarnpkg.com/bs-logger/-/bs-logger-0.2.6.tgz#eb7d365307a72cf974cc6cda76b68354ad336bd8"
integrity sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==
dependencies:
fast-json-stable-stringify "2.x"

bser@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/bser/-/bser-2.0.0.tgz#9ac78d3ed5d915804fd87acb158bc797147a1719"
Expand Down Expand Up @@ -4522,7 +4523,7 @@ buffer-es6@^4.9.2, buffer-es6@^4.9.3:
resolved "https://registry.yarnpkg.com/buffer-es6/-/buffer-es6-4.9.3.tgz#f26347b82df76fd37e18bcb5288c4970cfd5c404"
integrity sha1-8mNHuC33b9N+GLy1KIxJcM/VxAQ=

buffer-from@1.x, buffer-from@^1.0.0:
buffer-from@^1.0.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef"
integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==
Expand Down Expand Up @@ -7526,7 +7527,7 @@ fast-glob@^2.0.2, fast-glob@^2.2.4, fast-glob@^2.2.6:
merge2 "^1.2.3"
micromatch "^3.1.10"

fast-json-stable-stringify@2.x, fast-json-stable-stringify@^2.0.0:
fast-json-stable-stringify@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2"
integrity sha1-1RQsDK7msRifh9OnYREGT4bIu/I=
Expand Down Expand Up @@ -10487,13 +10488,6 @@ json3@^3.3.2:
resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1"
integrity sha1-PAQ0dD35Pi9cQq7nsZvLSDV19OE=

json5@2.x, json5@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.0.tgz#e7a0c62c48285c628d20a10b85c89bb807c32850"
integrity sha512-8Mh9h6xViijj36g7Dxi+Y4S6hNGV96vcJZr/SrlHh1LR/pEn/8j/+qIBbs44YKl69Lrfctp4QD+AdWLTMqEZAQ==
dependencies:
minimist "^1.2.0"

json5@^0.5.0, json5@^0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"
Expand All @@ -10506,6 +10500,13 @@ json5@^1.0.1:
dependencies:
minimist "^1.2.0"

json5@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.0.tgz#e7a0c62c48285c628d20a10b85c89bb807c32850"
integrity sha512-8Mh9h6xViijj36g7Dxi+Y4S6hNGV96vcJZr/SrlHh1LR/pEn/8j/+qIBbs44YKl69Lrfctp4QD+AdWLTMqEZAQ==
dependencies:
minimist "^1.2.0"

jsonc-parser@^1.0.0:
version "1.0.3"
resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-1.0.3.tgz#1d53d7160e401a783dbceabaad82473f80e6ad7e"
Expand Down Expand Up @@ -11390,7 +11391,7 @@ make-dir@^1.0.0, make-dir@^1.3.0:
dependencies:
pify "^3.0.0"

make-error@1.x, make-error@^1.3.5:
make-error@^1.3.5:
version "1.3.5"
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.5.tgz#efe4e81f6db28cadd605c70f29c831b58ef776c8"
integrity sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==
Expand Down Expand Up @@ -11906,7 +11907,7 @@ mkdirp@0.5.0:
dependencies:
minimist "0.0.8"

mkdirp@0.5.1, mkdirp@0.5.x, mkdirp@0.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1:
mkdirp@0.5.1, mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
integrity sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=
Expand Down Expand Up @@ -13725,6 +13726,15 @@ prosemirror-commands@^1.0.7:
prosemirror-state "^1.0.0"
prosemirror-transform "^1.0.0"

prosemirror-history@1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/prosemirror-history/-/prosemirror-history-1.0.3.tgz#5fb8591adfc272afaaf0b41bec64ee7d9522a118"
integrity sha512-IfFGbhafSx+R3aq7nLJGkXeu2iaUiP8mkU3aRu2uQcIIjU8Fq7RJfuvhIOJ2RNUoSyqF/ANkdTjnZ74F5eHs1Q==
dependencies:
prosemirror-state "^1.2.2"
prosemirror-transform "^1.0.0"
rope-sequence "^1.2.0"

prosemirror-inputrules@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/prosemirror-inputrules/-/prosemirror-inputrules-1.0.1.tgz#f63305fd966379f218e82ca76a2a9b328b66dc7b"
Expand Down Expand Up @@ -15115,7 +15125,7 @@ resolve@1.1.7:
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
integrity sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=

resolve@1.x, resolve@^1.1.6, resolve@^1.3.2, resolve@^1.4.0, resolve@^1.5.0, resolve@^1.7.1, resolve@^1.8.1, resolve@^1.9.0:
resolve@^1.1.6, resolve@^1.3.2, resolve@^1.4.0, resolve@^1.5.0, resolve@^1.7.1, resolve@^1.8.1, resolve@^1.9.0:
version "1.10.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.10.0.tgz#3bdaaeaf45cc07f375656dfd2e54ed0810b101ba"
integrity sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg==
Expand Down Expand Up @@ -15256,6 +15266,11 @@ rollup@1.1.2:
"@types/node" "*"
acorn "^6.0.5"

rope-sequence@^1.2.0:
version "1.2.2"
resolved "https://registry.yarnpkg.com/rope-sequence/-/rope-sequence-1.2.2.tgz#49c4e5c2f54a48e990b050926771e2871bcb31ce"
integrity sha1-ScTlwvVKSOmQsFCSZ3HihxvLMc4=

rsvp@^3.3.3:
version "3.6.2"
resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-3.6.2.tgz#2e96491599a96cde1b515d5674a8f7a91452926a"
Expand Down Expand Up @@ -15449,7 +15464,7 @@ semver-diff@^2.0.0:
dependencies:
semver "^5.0.3"

"semver@2 || 3 || 4 || 5", "semver@2.x || 3.x || 4 || 5", semver@^5.0.1, semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.4.1, semver@^5.5, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0:
"semver@2 || 3 || 4 || 5", "semver@2.x || 3.x || 4 || 5", semver@^5.0.1, semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0:
version "5.6.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004"
integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==
Expand Down Expand Up @@ -16930,21 +16945,6 @@ tryer@^1.0.0:
resolved "https://registry.yarnpkg.com/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8"
integrity sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==

ts-jest@23.10.5:
version "23.10.5"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-23.10.5.tgz#cdb550df4466a30489bf70ba867615799f388dd5"
integrity sha512-MRCs9qnGoyKgFc8adDEntAOP64fWK1vZKnOYU1o2HxaqjdJvGqmkLCPCnVq1/If4zkUmEjKPnCiUisTrlX2p2A==
dependencies:
bs-logger "0.x"
buffer-from "1.x"
fast-json-stable-stringify "2.x"
json5 "2.x"
make-error "1.x"
mkdirp "0.x"
resolve "1.x"
semver "^5.5"
yargs-parser "10.x"

ts-loader@5.3.3:
version "5.3.3"
resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-5.3.3.tgz#8b4af042e773132d86b3c99ef0acf3b4d325f473"
Expand Down Expand Up @@ -18243,7 +18243,7 @@ yallist@^3.0.0, yallist@^3.0.2:
resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.3.tgz#b4b049e314be545e3ce802236d6cd22cd91c3de9"
integrity sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==

yargs-parser@10.x, yargs-parser@^10.0.0, yargs-parser@^10.1.0:
yargs-parser@^10.0.0, yargs-parser@^10.1.0:
version "10.1.0"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-10.1.0.tgz#7202265b89f7e9e9f2e5765e0fe735a905edbaa8"
integrity sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ==
Expand Down

0 comments on commit fcfe418

Please sign in to comment.