From 75de574b6c1472ae599f2798834deb61d0417313 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Wed, 7 Nov 2018 17:16:15 +0100 Subject: [PATCH 1/4] Change the extension of generated files to .regen.js and .regen.tsx. Test a breaking change to the extension of generated files. Change the extension of generated fies to make it uniform across TypeScript and Flow, and independent from webpack plugins. No need for a special webpack plugin to read `.re.js` files instead of `.re` files. No difference in instructions to specify the current file in `bs.value` with TypeScript of Flow/Untyped. --- README.md | 8 ++---- examples/reason-react-example/clean.js | 18 ++++++++++++ .../reason-react-example/package-lock.json | 28 ++++--------------- examples/reason-react-example/package.json | 3 +- ...dules.re.js => FirstClassModules.regen.js} | 0 .../src/{Marcel.re.js => Marcel.regen.js} | 0 .../src/{Marcel1.re.js => Marcel1.regen.js} | 0 .../src/{Marcel2.re.js => Marcel2.regen.js} | 0 .../src/{Marcel3.re.js => Marcel3.regen.js} | 0 .../src/{Marcel4.re.js => Marcel4.regen.js} | 0 .../src/{Opaque.re.js => Opaque.regen.js} | 0 ...rray.re.js => TestImmutableArray.regen.js} | 0 ...Expansion.re.js => TypeExpansion.regen.js} | 2 +- .../{Component1.re.js => Component1.regen.js} | 2 +- .../{Component2.re.js => Component2.regen.js} | 0 .../{Component3.re.js => Component3.regen.js} | 0 .../basics/{Enums.re.js => Enums.regen.js} | 0 .../{Records.re.js => Records.regen.js} | 2 +- .../src/basics/SomeFlowTypes.js | 2 +- ...StrictLocal.re.js => StrictLocal.regen.js} | 0 .../basics/{Tuples.re.js => Tuples.regen.js} | 0 .../reason-react-example/src/basics/Types.re | 2 +- .../basics/{Types.re.js => Types.regen.js} | 0 .../src/basics/UseStrictLocalFromStrict.js | 2 +- ...mponents.re.js => ManyComponents.regen.js} | 0 .../{Navigator.re.js => Navigator.regen.js} | 0 ...RenameProps.re.js => RenameProps.regen.js} | 0 .../{Greeting.re.js => Greeting.regen.js} | 0 .../src/interop/InteropRoot.js | 8 +++--- .../src/interop/MyBannerWrapper.bs.js | 6 ++-- .../src/interop/MyBannerWrapper.re | 2 +- ...Wrapper.re.js => MyBannerWrapper.regen.js} | 0 .../src/interop/MyMath.js | 2 +- .../src/interop/WrapJsValue.bs.js | 8 +++--- .../src/interop/WrapJsValue.re | 8 +++--- ...WrapJsValue.re.js => WrapJsValue.regen.js} | 0 .../nested/{Nested.re.js => Nested.regen.js} | 2 +- .../reason-react-example/webpack.config.js | 6 ---- .../typescript-react-example/bsconfig.json | 3 +- examples/typescript-react-example/clean.js | 2 +- .../src/{Enums.tsx => Enums.regen.tsx} | 0 ...odules.tsx => FirstClassModules.regen.tsx} | 0 .../src/MyBannerWrapper.bs.js | 6 ++-- .../src/MyBannerWrapper.re | 2 +- ...rWrapper.tsx => MyBannerWrapper.regen.tsx} | 0 ...tedModules.tsx => NestedModules.regen.tsx} | 0 ...tsx => NestedModulesInSignature.regen.tsx} | 0 ...omponent.tsx => ReasonComponent.regen.tsx} | 4 +-- ...Array.tsx => TestImmutableArray.regen.tsx} | 0 ...apJsValue.tsx => UseWrapJsValue.regen.tsx} | 4 +-- .../src/WrapJsValue.bs.js | 6 ++-- .../src/WrapJsValue.re | 4 +-- ...{WrapJsValue.tsx => WrapJsValue.regen.tsx} | 0 ...omponents.tsx => ManyComponents.regen.tsx} | 0 .../typescript-react-example/src/index.tsx | 20 ++++++------- .../nested/{Records.tsx => Records.regen.tsx} | 0 .../nested/{Tuples.tsx => Tuples.regen.tsx} | 0 .../src/nested/{Types.tsx => Types.regen.tsx} | 0 examples/untyped-react-example/bsconfig.json | 6 ++-- examples/untyped-react-example/clean.js | 18 ++++++++++++ .../untyped-react-example/package-lock.json | 28 ++++--------------- examples/untyped-react-example/package.json | 3 +- .../src/{App.re.js => App.regen.js} | 0 examples/untyped-react-example/src/main.js | 2 +- .../untyped-react-example/webpack.config.js | 6 ---- src/EmitTyp.re | 10 ++----- 66 files changed, 108 insertions(+), 127 deletions(-) create mode 100644 examples/reason-react-example/clean.js rename examples/reason-react-example/src/{FirstClassModules.re.js => FirstClassModules.regen.js} (100%) rename examples/reason-react-example/src/{Marcel.re.js => Marcel.regen.js} (100%) rename examples/reason-react-example/src/{Marcel1.re.js => Marcel1.regen.js} (100%) rename examples/reason-react-example/src/{Marcel2.re.js => Marcel2.regen.js} (100%) rename examples/reason-react-example/src/{Marcel3.re.js => Marcel3.regen.js} (100%) rename examples/reason-react-example/src/{Marcel4.re.js => Marcel4.regen.js} (100%) rename examples/reason-react-example/src/{Opaque.re.js => Opaque.regen.js} (100%) rename examples/reason-react-example/src/{TestImmutableArray.re.js => TestImmutableArray.regen.js} (100%) rename examples/reason-react-example/src/{TypeExpansion.re.js => TypeExpansion.regen.js} (98%) rename examples/reason-react-example/src/basics/{Component1.re.js => Component1.regen.js} (99%) rename examples/reason-react-example/src/basics/{Component2.re.js => Component2.regen.js} (100%) rename examples/reason-react-example/src/basics/{Component3.re.js => Component3.regen.js} (100%) rename examples/reason-react-example/src/basics/{Enums.re.js => Enums.regen.js} (100%) rename examples/reason-react-example/src/basics/{Records.re.js => Records.regen.js} (97%) rename examples/reason-react-example/src/basics/{StrictLocal.re.js => StrictLocal.regen.js} (100%) rename examples/reason-react-example/src/basics/{Tuples.re.js => Tuples.regen.js} (100%) rename examples/reason-react-example/src/basics/{Types.re.js => Types.regen.js} (100%) rename examples/reason-react-example/src/components/{ManyComponents.re.js => ManyComponents.regen.js} (100%) rename examples/reason-react-example/src/components/{Navigator.re.js => Navigator.regen.js} (100%) rename examples/reason-react-example/src/components/{RenameProps.re.js => RenameProps.regen.js} (100%) rename examples/reason-react-example/src/interop/{Greeting.re.js => Greeting.regen.js} (100%) rename examples/reason-react-example/src/interop/{MyBannerWrapper.re.js => MyBannerWrapper.regen.js} (100%) rename examples/reason-react-example/src/interop/{WrapJsValue.re.js => WrapJsValue.regen.js} (100%) rename examples/reason-react-example/src/nested/{Nested.re.js => Nested.regen.js} (97%) rename examples/typescript-react-example/src/{Enums.tsx => Enums.regen.tsx} (100%) rename examples/typescript-react-example/src/{FirstClassModules.tsx => FirstClassModules.regen.tsx} (100%) rename examples/typescript-react-example/src/{MyBannerWrapper.tsx => MyBannerWrapper.regen.tsx} (100%) rename examples/typescript-react-example/src/{NestedModules.tsx => NestedModules.regen.tsx} (100%) rename examples/typescript-react-example/src/{NestedModulesInSignature.tsx => NestedModulesInSignature.regen.tsx} (100%) rename examples/typescript-react-example/src/{ReasonComponent.tsx => ReasonComponent.regen.tsx} (95%) rename examples/typescript-react-example/src/{TestImmutableArray.tsx => TestImmutableArray.regen.tsx} (100%) rename examples/typescript-react-example/src/{UseWrapJsValue.tsx => UseWrapJsValue.regen.tsx} (93%) rename examples/typescript-react-example/src/{WrapJsValue.tsx => WrapJsValue.regen.tsx} (100%) rename examples/typescript-react-example/src/components/{ManyComponents.tsx => ManyComponents.regen.tsx} (100%) rename examples/typescript-react-example/src/nested/{Records.tsx => Records.regen.tsx} (100%) rename examples/typescript-react-example/src/nested/{Tuples.tsx => Tuples.regen.tsx} (100%) rename examples/typescript-react-example/src/nested/{Types.tsx => Types.regen.tsx} (100%) create mode 100644 examples/untyped-react-example/clean.js rename examples/untyped-react-example/src/{App.re.js => App.regen.js} (100%) diff --git a/README.md b/README.md index 11d38a462..32779cbf6 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,7 @@ To import a function `realValue` from JS module `MyMath.ts` (or `MyMath.js`): ```reason [@genType.import "./MyMath"] /* This is the module to import from. */ -[@bs.module "./WrapJsValue"] /* Or "./WrapJsValue.re" for Flow/untyped. */ +[@bs.module "./WrapJsValue.regen"] /* Always the name of the current file. */ /* Name and type of the JS value to import. */ external realValue: complexNumber => float = ""; @@ -129,7 +129,7 @@ external realValue: complexNumber => float = ""; Because of the `external` keyword, it's clear from context that this is an import, so you can also just use `@genType` and omit `.import`. -**NOTE** The argument of `@bs.module` is different for the "typescript" and the "flow"/"untyped" back-ends. And must always be the name of the current file (In future, with compiler support, this could be automatically generated). +**NOTE** The argument of `@bs.module`must always be the name of the current file (In future, with compiler support, this could be automatically generated). ### Export and Import React Components @@ -149,7 +149,7 @@ To import and wrap a ReactJS component for use by ReasonReact, the type of the ` ```reason [@genType.import "./MyBanner"] /* Module with the JS component to be wrapped. */ -[@bs.module "./MyBannerWrapper"] /* Or "./MyBannerWrapper.re" for Flow/untyped. */ +[@bs.module "./MyBannerWrapper.regen"] /* Always the name of the current file. */ /* The make function will be automatically generated from the types below. */ external make: (~show: bool, ~message: option(message)=?, 'a) => @@ -163,8 +163,6 @@ external make: The type of `make` must have a named argument for each prop in the JS component. Optional props have option type. The `make` function will be generated by `genType`. -**NOTE** The argument of `@bs.module` is different for the "typescript" and the "flow"/"untyped" back-ends. - ### Type Expansion and @genType.opaque If an exported type `persons` references other types in its definition, those types are also exported by default, as long as they are defined in the same file: diff --git a/examples/reason-react-example/clean.js b/examples/reason-react-example/clean.js new file mode 100644 index 000000000..718fe2fb7 --- /dev/null +++ b/examples/reason-react-example/clean.js @@ -0,0 +1,18 @@ +const glob = require("glob"); +const fs = require("fs"); +const child_process = require("child_process"); + +glob.glob("src/**/*.bs.js", function(er, files) { + files.forEach(fileBsJs => { + const fileTsx = fileBsJs.substring(0, fileBsJs.length - 6) + "regen.js"; + fs.unlink(fileTsx, err => { + return; + }); + }); +}); + +const isWindows = /^win/i.test(process.platform); + +child_process + .spawn("bsb", ["-clean-world"], { stdio: "inherit", stderr: "inherit", shell: isWindows }) + .on("exit", code => process.exit(code)); diff --git a/examples/reason-react-example/package-lock.json b/examples/reason-react-example/package-lock.json index b79016524..a0c3886fd 100644 --- a/examples/reason-react-example/package-lock.json +++ b/examples/reason-react-example/package-lock.json @@ -1241,7 +1241,8 @@ "big.js": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/big.js/-/big.js-3.2.0.tgz", - "integrity": "sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q==" + "integrity": "sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q==", + "dev": true }, "binary-extensions": { "version": "1.12.0", @@ -1960,7 +1961,8 @@ "emojis-list": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", - "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=" + "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=", + "dev": true }, "encoding": { "version": "0.1.12", @@ -2171,14 +2173,6 @@ } } }, - "extension-replace-loader": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/extension-replace-loader/-/extension-replace-loader-0.0.1.tgz", - "integrity": "sha1-nfqEf2vdlMyc8Rq3IizFEil6aI4=", - "requires": { - "loader-utils": "^0.2.14" - } - }, "extglob": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", @@ -3446,7 +3440,8 @@ "json5": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", - "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=" + "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", + "dev": true }, "kind-of": { "version": "6.0.2", @@ -3481,17 +3476,6 @@ "integrity": "sha512-By6ZFY7ETWOc9RFaAIb23IjJVcM4dvJC/N57nmdz9RSkMXvAXGI7SyVlAw3v8vjtDRlqThgVDVmTnr9fqMlxkw==", "dev": true }, - "loader-utils": { - "version": "0.2.17", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-0.2.17.tgz", - "integrity": "sha1-+G5jdNQyBabmxg6RlvF8Apm/s0g=", - "requires": { - "big.js": "^3.1.3", - "emojis-list": "^2.0.0", - "json5": "^0.5.0", - "object-assign": "^4.0.1" - } - }, "locate-path": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", diff --git a/examples/reason-react-example/package.json b/examples/reason-react-example/package.json index 7efd2361b..2ec27ee90 100644 --- a/examples/reason-react-example/package.json +++ b/examples/reason-react-example/package.json @@ -7,7 +7,7 @@ "scripts": { "build": "node ../run_bsb.js -make-world", "start": "node ../run_bsb.js -make-world -w", - "clean": "bsb -clean-world", + "clean": "node clean.js", "test": "exit 0", "webpack": "webpack -w", "webpack:production": "webpack --env.NODE_ENV=production" @@ -16,7 +16,6 @@ "author": "", "license": "MIT", "dependencies": { - "extension-replace-loader": "^0.0.1", "react": "^15.4.2", "react-dom": "^15.4.2", "reason-react": "^0.5.3" diff --git a/examples/reason-react-example/src/FirstClassModules.re.js b/examples/reason-react-example/src/FirstClassModules.regen.js similarity index 100% rename from examples/reason-react-example/src/FirstClassModules.re.js rename to examples/reason-react-example/src/FirstClassModules.regen.js diff --git a/examples/reason-react-example/src/Marcel.re.js b/examples/reason-react-example/src/Marcel.regen.js similarity index 100% rename from examples/reason-react-example/src/Marcel.re.js rename to examples/reason-react-example/src/Marcel.regen.js diff --git a/examples/reason-react-example/src/Marcel1.re.js b/examples/reason-react-example/src/Marcel1.regen.js similarity index 100% rename from examples/reason-react-example/src/Marcel1.re.js rename to examples/reason-react-example/src/Marcel1.regen.js diff --git a/examples/reason-react-example/src/Marcel2.re.js b/examples/reason-react-example/src/Marcel2.regen.js similarity index 100% rename from examples/reason-react-example/src/Marcel2.re.js rename to examples/reason-react-example/src/Marcel2.regen.js diff --git a/examples/reason-react-example/src/Marcel3.re.js b/examples/reason-react-example/src/Marcel3.regen.js similarity index 100% rename from examples/reason-react-example/src/Marcel3.re.js rename to examples/reason-react-example/src/Marcel3.regen.js diff --git a/examples/reason-react-example/src/Marcel4.re.js b/examples/reason-react-example/src/Marcel4.regen.js similarity index 100% rename from examples/reason-react-example/src/Marcel4.re.js rename to examples/reason-react-example/src/Marcel4.regen.js diff --git a/examples/reason-react-example/src/Opaque.re.js b/examples/reason-react-example/src/Opaque.regen.js similarity index 100% rename from examples/reason-react-example/src/Opaque.re.js rename to examples/reason-react-example/src/Opaque.regen.js diff --git a/examples/reason-react-example/src/TestImmutableArray.re.js b/examples/reason-react-example/src/TestImmutableArray.regen.js similarity index 100% rename from examples/reason-react-example/src/TestImmutableArray.re.js rename to examples/reason-react-example/src/TestImmutableArray.regen.js diff --git a/examples/reason-react-example/src/TypeExpansion.re.js b/examples/reason-react-example/src/TypeExpansion.regen.js similarity index 98% rename from examples/reason-react-example/src/TypeExpansion.re.js rename to examples/reason-react-example/src/TypeExpansion.regen.js index a3ade02bd..36a89afd3 100644 --- a/examples/reason-react-example/src/TypeExpansion.re.js +++ b/examples/reason-react-example/src/TypeExpansion.regen.js @@ -7,7 +7,7 @@ // $FlowExpectedError: Reason checked type sufficiently const TypeExpansionBS = require('./TypeExpansion.bs'); -import type {person as Tuples_person} from '../src/basics/Tuples.re'; +import type {person as Tuples_person} from '../src/basics/Tuples.regen'; export type personFromTuples = Tuples_person; diff --git a/examples/reason-react-example/src/basics/Component1.re.js b/examples/reason-react-example/src/basics/Component1.regen.js similarity index 99% rename from examples/reason-react-example/src/basics/Component1.re.js rename to examples/reason-react-example/src/basics/Component1.regen.js index 796f76844..b3ca0604b 100644 --- a/examples/reason-react-example/src/basics/Component1.re.js +++ b/examples/reason-react-example/src/basics/Component1.regen.js @@ -15,7 +15,7 @@ const ReasonReact = require('reason-react/src/ReasonReact.js'); import type {list} from '../../src/shims/ReasonPervasives.shim'; -import type {variant as Component2_variant} from './Component2.re'; +import type {variant as Component2_variant} from './Component2.regen'; export type Props = {|+message?: string, +children?: mixed|}; diff --git a/examples/reason-react-example/src/basics/Component2.re.js b/examples/reason-react-example/src/basics/Component2.regen.js similarity index 100% rename from examples/reason-react-example/src/basics/Component2.re.js rename to examples/reason-react-example/src/basics/Component2.regen.js diff --git a/examples/reason-react-example/src/basics/Component3.re.js b/examples/reason-react-example/src/basics/Component3.regen.js similarity index 100% rename from examples/reason-react-example/src/basics/Component3.re.js rename to examples/reason-react-example/src/basics/Component3.regen.js diff --git a/examples/reason-react-example/src/basics/Enums.re.js b/examples/reason-react-example/src/basics/Enums.regen.js similarity index 100% rename from examples/reason-react-example/src/basics/Enums.re.js rename to examples/reason-react-example/src/basics/Enums.regen.js diff --git a/examples/reason-react-example/src/basics/Records.re.js b/examples/reason-react-example/src/basics/Records.regen.js similarity index 97% rename from examples/reason-react-example/src/basics/Records.re.js rename to examples/reason-react-example/src/basics/Records.regen.js index 234ca7704..af39da082 100644 --- a/examples/reason-react-example/src/basics/Records.re.js +++ b/examples/reason-react-example/src/basics/Records.regen.js @@ -7,7 +7,7 @@ // $FlowExpectedError: Reason checked type sufficiently const RecordsBS = require('./Records.bs'); -import type {weekday as Types_weekday} from './Types.re'; +import type {weekday as Types_weekday} from './Types.regen'; export type coord = {| +x: number, diff --git a/examples/reason-react-example/src/basics/SomeFlowTypes.js b/examples/reason-react-example/src/basics/SomeFlowTypes.js index 4281b62b3..b21fd527f 100644 --- a/examples/reason-react-example/src/basics/SomeFlowTypes.js +++ b/examples/reason-react-example/src/basics/SomeFlowTypes.js @@ -1,6 +1,6 @@ /* @flow strict */ -const Types = require("./Types.re"); +const Types = require("./Types.regen"); export type anInterestingFlowType = { an: string, diff --git a/examples/reason-react-example/src/basics/StrictLocal.re.js b/examples/reason-react-example/src/basics/StrictLocal.regen.js similarity index 100% rename from examples/reason-react-example/src/basics/StrictLocal.re.js rename to examples/reason-react-example/src/basics/StrictLocal.regen.js diff --git a/examples/reason-react-example/src/basics/Tuples.re.js b/examples/reason-react-example/src/basics/Tuples.regen.js similarity index 100% rename from examples/reason-react-example/src/basics/Tuples.re.js rename to examples/reason-react-example/src/basics/Tuples.regen.js diff --git a/examples/reason-react-example/src/basics/Types.re b/examples/reason-react-example/src/basics/Types.re index 29b58d441..c4e3100e3 100644 --- a/examples/reason-react-example/src/basics/Types.re +++ b/examples/reason-react-example/src/basics/Types.re @@ -75,7 +75,7 @@ type someMutableFields = { [@bs.set] "mutable2": string, }; -[@genType.import "./name-with-dashes"] [@bs.module "./Types.re"] +[@genType.import "./name-with-dashes"] [@bs.module "./Types.regen"] external foo: int => int = ""; [@genType.opaque] diff --git a/examples/reason-react-example/src/basics/Types.re.js b/examples/reason-react-example/src/basics/Types.regen.js similarity index 100% rename from examples/reason-react-example/src/basics/Types.re.js rename to examples/reason-react-example/src/basics/Types.regen.js diff --git a/examples/reason-react-example/src/basics/UseStrictLocalFromStrict.js b/examples/reason-react-example/src/basics/UseStrictLocalFromStrict.js index d820938bf..6d96769a6 100644 --- a/examples/reason-react-example/src/basics/UseStrictLocalFromStrict.js +++ b/examples/reason-react-example/src/basics/UseStrictLocalFromStrict.js @@ -1,3 +1,3 @@ /* @flow strict */ -import type {someNonStrictType} from './StrictLocal.re'; +import type {someNonStrictType} from './StrictLocal.regen'; diff --git a/examples/reason-react-example/src/components/ManyComponents.re.js b/examples/reason-react-example/src/components/ManyComponents.regen.js similarity index 100% rename from examples/reason-react-example/src/components/ManyComponents.re.js rename to examples/reason-react-example/src/components/ManyComponents.regen.js diff --git a/examples/reason-react-example/src/components/Navigator.re.js b/examples/reason-react-example/src/components/Navigator.regen.js similarity index 100% rename from examples/reason-react-example/src/components/Navigator.re.js rename to examples/reason-react-example/src/components/Navigator.regen.js diff --git a/examples/reason-react-example/src/components/RenameProps.re.js b/examples/reason-react-example/src/components/RenameProps.regen.js similarity index 100% rename from examples/reason-react-example/src/components/RenameProps.re.js rename to examples/reason-react-example/src/components/RenameProps.regen.js diff --git a/examples/reason-react-example/src/interop/Greeting.re.js b/examples/reason-react-example/src/interop/Greeting.regen.js similarity index 100% rename from examples/reason-react-example/src/interop/Greeting.re.js rename to examples/reason-react-example/src/interop/Greeting.regen.js diff --git a/examples/reason-react-example/src/interop/InteropRoot.js b/examples/reason-react-example/src/interop/InteropRoot.js index 84237ccbf..b4e8c843c 100644 --- a/examples/reason-react-example/src/interop/InteropRoot.js +++ b/examples/reason-react-example/src/interop/InteropRoot.js @@ -3,10 +3,10 @@ const ReactDOM = require("react-dom"); const React = require("react"); -const GreetingRe = require("./Greeting.re"); +const GreetingRe = require("./Greeting.regen"); // Import a ReasonReact component! -const PageReason = require("./Greeting.re").default; +const PageReason = require("./Greeting.regen").default; const consoleLog = console.log; @@ -19,7 +19,7 @@ const helloWorld = GreetingRe.concat("++", helloWorldList); const someNumber: number = GreetingRe.testDefaultArgs({ y: 10 }); -const WrapJsValue = require("./WrapJsValue.re"); +const WrapJsValue = require("./WrapJsValue.regen"); consoleLog("interopRoot.js roundedNumber:", WrapJsValue.roundedNumber); consoleLog("interopRoot.js areaValue:", WrapJsValue.areaValue); @@ -34,7 +34,7 @@ consoleLog("interopRoot.js callMyAreaDirectly:", callMyAreaDirectly); consoleLog("anInterestingFlowType ", require("../basics/SomeFlowTypes").c); -const Enums = require("../basics/Enums.re"); +const Enums = require("../basics/Enums.regen"); consoleLog("Enums: swap(sunday) =", Enums.swap("sunday")); consoleLog("Enums: fortytwoOK is", Enums.fortytwoOK); diff --git a/examples/reason-react-example/src/interop/MyBannerWrapper.bs.js b/examples/reason-react-example/src/interop/MyBannerWrapper.bs.js index 929e7292f..819859164 100644 --- a/examples/reason-react-example/src/interop/MyBannerWrapper.bs.js +++ b/examples/reason-react-example/src/interop/MyBannerWrapper.bs.js @@ -1,11 +1,11 @@ // Generated by BUCKLESCRIPT VERSION 4.0.7, PLEASE EDIT WITH CARE 'use strict'; -var MyBannerWrapperRe = require("./MyBannerWrapper.re"); +var MyBannerWrapperRegen = require("./MyBannerWrapper.regen"); function make(prim, prim$1, prim$2) { - return MyBannerWrapperRe.make(prim, prim$1, prim$2); + return MyBannerWrapperRegen.make(prim, prim$1, prim$2); } exports.make = make; -/* ./MyBannerWrapper.re Not a pure module */ +/* ./MyBannerWrapper.regen Not a pure module */ diff --git a/examples/reason-react-example/src/interop/MyBannerWrapper.re b/examples/reason-react-example/src/interop/MyBannerWrapper.re index 0c58479f9..f9ddb3694 100644 --- a/examples/reason-react-example/src/interop/MyBannerWrapper.re +++ b/examples/reason-react-example/src/interop/MyBannerWrapper.re @@ -2,7 +2,7 @@ * Wrap component MyBanner to be used from Reason. */ [@genType.import "./MyBanner.component"] /* Module with the JS component to be wrapped. */ -[@bs.module "./MyBannerWrapper.re"] /* This must always be the name of the current module. */ +[@bs.module "./MyBannerWrapper.regen"] /* This must always be the name of the current module. */ /* The make function will be automatically generated from the types below. */ external make: (~show: bool) => diff --git a/examples/reason-react-example/src/interop/MyBannerWrapper.re.js b/examples/reason-react-example/src/interop/MyBannerWrapper.regen.js similarity index 100% rename from examples/reason-react-example/src/interop/MyBannerWrapper.re.js rename to examples/reason-react-example/src/interop/MyBannerWrapper.regen.js diff --git a/examples/reason-react-example/src/interop/MyMath.js b/examples/reason-react-example/src/interop/MyMath.js index f119bd1fd..0cc7188ae 100644 --- a/examples/reason-react-example/src/interop/MyMath.js +++ b/examples/reason-react-example/src/interop/MyMath.js @@ -1,6 +1,6 @@ /* @flow strict */ -const WrapJsValue = require("./WrapJsValue.re"); +const WrapJsValue = require("./WrapJsValue.regen"); export const round: number => number = Math.round; diff --git a/examples/reason-react-example/src/interop/WrapJsValue.bs.js b/examples/reason-react-example/src/interop/WrapJsValue.bs.js index a09105aba..31dea3cc6 100644 --- a/examples/reason-react-example/src/interop/WrapJsValue.bs.js +++ b/examples/reason-react-example/src/interop/WrapJsValue.bs.js @@ -1,15 +1,15 @@ // Generated by BUCKLESCRIPT VERSION 4.0.7, PLEASE EDIT WITH CARE 'use strict'; -var WrapJsValueRe = require("./WrapJsValue.re"); +var WrapJsValueRegen = require("./WrapJsValue.regen"); function myArea(prim) { - return WrapJsValueRe.area(prim); + return WrapJsValueRegen.area(prim); } -var roundedNumber = WrapJsValueRe.round(1.8); +var roundedNumber = WrapJsValueRegen.round(1.8); -var areaValue = WrapJsValueRe.area(/* record */[ +var areaValue = WrapJsValueRegen.area(/* record */[ /* x */3, /* y */undefined ]); diff --git a/examples/reason-react-example/src/interop/WrapJsValue.re b/examples/reason-react-example/src/interop/WrapJsValue.re index e65630acb..26725c3db 100644 --- a/examples/reason-react-example/src/interop/WrapJsValue.re +++ b/examples/reason-react-example/src/interop/WrapJsValue.re @@ -2,7 +2,7 @@ * Wrap JS values to be used from Reason */ [@genType.import "./MyMath"] /* This is the module to import from. */ -[@bs.module "./WrapJsValue.re"] /* This must always be the name of the current module. */ +[@bs.module "./WrapJsValue.regen"] /* This must always be the name of the current module. */ /* Name and type of the JS value to bind to. */ external round: float => float = ""; @@ -13,7 +13,7 @@ type point = { }; [@genType.import "./MyMath"] /* This is the module to import from. */ -[@bs.module "./WrapJsValue.re"] /* This must always be the name of the current module. */ +[@bs.module "./WrapJsValue.regen"] /* This must always be the name of the current module. */ /* Name and type of the JS value to bind to. */ external area: point => int = ""; @@ -30,12 +30,12 @@ let areaValue = area({x: 3, y: None}); type myArray('a); [@genType.import "./MyMath"] /* This is the module to import from. */ -[@bs.module "./WrapJsValue.re"] /* This must always be the name of the current module. */ +[@bs.module "./WrapJsValue.regen"] /* This must always be the name of the current module. */ /* Name and type of the JS value to bind to. */ external getValueAtIndex: (myArray(string), int) => string = ""; [@genType.import "./MyMath"] /* This is the module to import from. */ -[@bs.module "./WrapJsValue.re"] /* This must always be the name of the current module. */ +[@bs.module "./WrapJsValue.regen"] /* This must always be the name of the current module. */ /* Name and type of the JS value to bind to. */ external functionWithRenamedArgument: string => [@genType.as "ArgRenamed"] ((~argToRename: string) => string) = diff --git a/examples/reason-react-example/src/interop/WrapJsValue.re.js b/examples/reason-react-example/src/interop/WrapJsValue.regen.js similarity index 100% rename from examples/reason-react-example/src/interop/WrapJsValue.re.js rename to examples/reason-react-example/src/interop/WrapJsValue.regen.js diff --git a/examples/reason-react-example/src/nested/Nested.re.js b/examples/reason-react-example/src/nested/Nested.regen.js similarity index 97% rename from examples/reason-react-example/src/nested/Nested.re.js rename to examples/reason-react-example/src/nested/Nested.regen.js index 3f499bc23..a72c297cb 100644 --- a/examples/reason-react-example/src/nested/Nested.re.js +++ b/examples/reason-react-example/src/nested/Nested.regen.js @@ -10,7 +10,7 @@ const CreateBucklescriptBlock = require('bs-platform/lib/js/block.js'); // $FlowExpectedError: Reason checked type sufficiently const NestedBS = require('./Nested.bs'); -import type {variant as Component2_variant} from '../../src/basics/Component2.re'; +import type {variant as Component2_variant} from '../../src/basics/Component2.regen'; export opaque type VariantA = mixed; diff --git a/examples/reason-react-example/webpack.config.js b/examples/reason-react-example/webpack.config.js index 4c86ed1b0..2a344a0be 100644 --- a/examples/reason-react-example/webpack.config.js +++ b/examples/reason-react-example/webpack.config.js @@ -26,12 +26,6 @@ module.exports = { ] } } - }, - { - loader: "extension-replace-loader", - query: { - exts: [{ from: ".re", to: ".re.js" }] - } } ] } diff --git a/examples/typescript-react-example/bsconfig.json b/examples/typescript-react-example/bsconfig.json index 70078f39e..aaf4048d0 100644 --- a/examples/typescript-react-example/bsconfig.json +++ b/examples/typescript-react-example/bsconfig.json @@ -9,8 +9,7 @@ "all": false, "basic": false }, - "exportInterfaces": false, - "generatedFileExtension": "" + "exportInterfaces": false }, "name": "sample-typescript-app", "reason": { diff --git a/examples/typescript-react-example/clean.js b/examples/typescript-react-example/clean.js index 38290821a..1ff3443cd 100644 --- a/examples/typescript-react-example/clean.js +++ b/examples/typescript-react-example/clean.js @@ -4,7 +4,7 @@ const child_process = require("child_process"); glob.glob("src/**/*.bs.js", function(er, files) { files.forEach(fileBsJs => { - const fileTsx = fileBsJs.substring(0, fileBsJs.length - 6) + ".tsx"; + const fileTsx = fileBsJs.substring(0, fileBsJs.length - 6) + ".regen.tsx"; fs.unlink(fileTsx, err => { return; }); diff --git a/examples/typescript-react-example/src/Enums.tsx b/examples/typescript-react-example/src/Enums.regen.tsx similarity index 100% rename from examples/typescript-react-example/src/Enums.tsx rename to examples/typescript-react-example/src/Enums.regen.tsx diff --git a/examples/typescript-react-example/src/FirstClassModules.tsx b/examples/typescript-react-example/src/FirstClassModules.regen.tsx similarity index 100% rename from examples/typescript-react-example/src/FirstClassModules.tsx rename to examples/typescript-react-example/src/FirstClassModules.regen.tsx diff --git a/examples/typescript-react-example/src/MyBannerWrapper.bs.js b/examples/typescript-react-example/src/MyBannerWrapper.bs.js index 8529bc49f..f92b1c191 100644 --- a/examples/typescript-react-example/src/MyBannerWrapper.bs.js +++ b/examples/typescript-react-example/src/MyBannerWrapper.bs.js @@ -2,11 +2,11 @@ 'use strict'; var Js_primitive = require("bs-platform/lib/js/js_primitive.js"); -var MyBannerWrapper = require("./MyBannerWrapper"); +var MyBannerWrapperRegen = require("./MyBannerWrapper.regen"); function make(prim, prim$1, prim$2) { - return MyBannerWrapper.make(prim, prim$1 !== undefined ? Js_primitive.valFromOption(prim$1) : undefined, prim$2); + return MyBannerWrapperRegen.make(prim, prim$1 !== undefined ? Js_primitive.valFromOption(prim$1) : undefined, prim$2); } exports.make = make; -/* ./MyBannerWrapper Not a pure module */ +/* ./MyBannerWrapper.regen Not a pure module */ diff --git a/examples/typescript-react-example/src/MyBannerWrapper.re b/examples/typescript-react-example/src/MyBannerWrapper.re index 65e9f31f8..daf825901 100644 --- a/examples/typescript-react-example/src/MyBannerWrapper.re +++ b/examples/typescript-react-example/src/MyBannerWrapper.re @@ -6,7 +6,7 @@ type message = {text: string}; [@genType.import "./MyBanner"] /* Module with the JS component to be wrapped. */ -[@bs.module "./MyBannerWrapper"] /* This must always be the name of the current module. */ +[@bs.module "./MyBannerWrapper.regen"] /* This must always be the name of the current module. */ /* The make function will be automatically generated from the types below. */ external make: (~show: bool, ~message: option(message)=?, 'a) => diff --git a/examples/typescript-react-example/src/MyBannerWrapper.tsx b/examples/typescript-react-example/src/MyBannerWrapper.regen.tsx similarity index 100% rename from examples/typescript-react-example/src/MyBannerWrapper.tsx rename to examples/typescript-react-example/src/MyBannerWrapper.regen.tsx diff --git a/examples/typescript-react-example/src/NestedModules.tsx b/examples/typescript-react-example/src/NestedModules.regen.tsx similarity index 100% rename from examples/typescript-react-example/src/NestedModules.tsx rename to examples/typescript-react-example/src/NestedModules.regen.tsx diff --git a/examples/typescript-react-example/src/NestedModulesInSignature.tsx b/examples/typescript-react-example/src/NestedModulesInSignature.regen.tsx similarity index 100% rename from examples/typescript-react-example/src/NestedModulesInSignature.tsx rename to examples/typescript-react-example/src/NestedModulesInSignature.regen.tsx diff --git a/examples/typescript-react-example/src/ReasonComponent.tsx b/examples/typescript-react-example/src/ReasonComponent.regen.tsx similarity index 95% rename from examples/typescript-react-example/src/ReasonComponent.tsx rename to examples/typescript-react-example/src/ReasonComponent.regen.tsx index 68ea89486..4da16b371 100644 --- a/examples/typescript-react-example/src/ReasonComponent.tsx +++ b/examples/typescript-react-example/src/ReasonComponent.regen.tsx @@ -14,11 +14,11 @@ const ReasonReact = require('reason-react/src/ReasonReact.js'); import {Mouse_t as ReactEvent_Mouse_t} from '../src/shims/ReactEvent.shim'; -import {coord as Records_coord} from '../src/nested/Records'; +import {coord as Records_coord} from '../src/nested/Records.regen'; import {list} from '../src/shims/ReasonPervasives.shim'; -import {t as Types_t} from '../src/nested/Types'; +import {t as Types_t} from '../src/nested/Types.regen'; // tslint:disable-next-line:interface-over-type-literal export type person = { diff --git a/examples/typescript-react-example/src/TestImmutableArray.tsx b/examples/typescript-react-example/src/TestImmutableArray.regen.tsx similarity index 100% rename from examples/typescript-react-example/src/TestImmutableArray.tsx rename to examples/typescript-react-example/src/TestImmutableArray.regen.tsx diff --git a/examples/typescript-react-example/src/UseWrapJsValue.tsx b/examples/typescript-react-example/src/UseWrapJsValue.regen.tsx similarity index 93% rename from examples/typescript-react-example/src/UseWrapJsValue.tsx rename to examples/typescript-react-example/src/UseWrapJsValue.regen.tsx index c85a146e7..6024a4880 100644 --- a/examples/typescript-react-example/src/UseWrapJsValue.tsx +++ b/examples/typescript-react-example/src/UseWrapJsValue.regen.tsx @@ -3,9 +3,9 @@ // tslint:disable-next-line:no-var-requires const UseWrapJsValueBS = require('./UseWrapJsValue.bs'); -import {AbsoluteValue_t as WrapJsValue_AbsoluteValue_t} from './WrapJsValue'; +import {AbsoluteValue_t as WrapJsValue_AbsoluteValue_t} from './WrapJsValue.regen'; -import {stringFunction as WrapJsValue_stringFunction} from './WrapJsValue'; +import {stringFunction as WrapJsValue_stringFunction} from './WrapJsValue.regen'; export const useGetProp: (_1:WrapJsValue_AbsoluteValue_t) => number = UseWrapJsValueBS.useGetProp; diff --git a/examples/typescript-react-example/src/WrapJsValue.bs.js b/examples/typescript-react-example/src/WrapJsValue.bs.js index 0374f92c2..f704e92ea 100644 --- a/examples/typescript-react-example/src/WrapJsValue.bs.js +++ b/examples/typescript-react-example/src/WrapJsValue.bs.js @@ -1,11 +1,11 @@ // Generated by BUCKLESCRIPT VERSION 4.0.7, PLEASE EDIT WITH CARE 'use strict'; -var WrapJsValue = require("./WrapJsValue"); +var WrapJsValueRegen = require("./WrapJsValue.regen"); -var roundedNumber = WrapJsValue.round(1.8); +var roundedNumber = WrapJsValueRegen.round(1.8); -var areaValue = WrapJsValue.area(/* record */[ +var areaValue = WrapJsValueRegen.area(/* record */[ /* x */3, /* y */undefined ]); diff --git a/examples/typescript-react-example/src/WrapJsValue.re b/examples/typescript-react-example/src/WrapJsValue.re index f867e4bbb..abbaf2bb3 100644 --- a/examples/typescript-react-example/src/WrapJsValue.re +++ b/examples/typescript-react-example/src/WrapJsValue.re @@ -2,7 +2,7 @@ * Wrap JS values to be used from Reason */ [@genType.import "./MyMath"] /* This is the module to import from. */ -[@bs.module "./WrapJsValue"] /* This must always be the name of the current module. */ +[@bs.module "./WrapJsValue.regen"] /* This must always be the name of the current module. */ /* Name and type of the JS value to bind to. */ external round: float => float = ""; @@ -13,7 +13,7 @@ type point = { }; [@genType.import "./MyMath"] /* This is the module to import from. */ -[@bs.module "./WrapJsValue"] /* This must always be the name of the current module. */ +[@bs.module "./WrapJsValue.regen"] /* This must always be the name of the current module. */ /* Name and type of the JS value to bind to. */ external area: point => int = ""; diff --git a/examples/typescript-react-example/src/WrapJsValue.tsx b/examples/typescript-react-example/src/WrapJsValue.regen.tsx similarity index 100% rename from examples/typescript-react-example/src/WrapJsValue.tsx rename to examples/typescript-react-example/src/WrapJsValue.regen.tsx diff --git a/examples/typescript-react-example/src/components/ManyComponents.tsx b/examples/typescript-react-example/src/components/ManyComponents.regen.tsx similarity index 100% rename from examples/typescript-react-example/src/components/ManyComponents.tsx rename to examples/typescript-react-example/src/components/ManyComponents.regen.tsx diff --git a/examples/typescript-react-example/src/index.tsx b/examples/typescript-react-example/src/index.tsx index 2583b2d1b..94310c03b 100644 --- a/examples/typescript-react-example/src/index.tsx +++ b/examples/typescript-react-example/src/index.tsx @@ -1,17 +1,17 @@ import * as React from "react"; import * as ReactDOM from "react-dom"; import App from "./App"; -import * as Enums from "./Enums"; +import * as Enums from "./Enums.regen"; import "./index.css"; import * as MyMath from "./MyMath"; -import * as Records from "./nested/Records"; -import * as Types from "./nested/Types"; -import { Universe_Nested2_Nested3_nested3Value } from "./NestedModules"; -import ReasonComponent from "./ReasonComponent"; -import { A, B, minus, tToString } from "./ReasonComponent"; -import { t, TA, TB } from "./ReasonComponent"; +import * as Records from "./nested/Records.regen"; +import * as Types from "./nested/Types.regen"; +import { Universe_Nested2_Nested3_nested3Value } from "./NestedModules.regen"; +import ReasonComponent from "./ReasonComponent.regen"; +import { A, B, minus, tToString } from "./ReasonComponent.regen"; +import { t, TA, TB } from "./ReasonComponent.regen"; import registerServiceWorker from "./registerServiceWorker"; -import * as WrapJsValue from "./WrapJsValue"; +import * as WrapJsValue from "./WrapJsValue.regen"; const minusOne: number = minus({ second: 1 }); @@ -37,9 +37,9 @@ const businesses = [ const addresses = Records.findAllAddresses(businesses); -import { roundedNumber } from "./WrapJsValue"; +import { roundedNumber } from "./WrapJsValue.regen"; consoleLog("index.tsx roundedNumber:", roundedNumber); -import { areaValue } from "./WrapJsValue"; +import { areaValue } from "./WrapJsValue.regen"; consoleLog("index.tsx areaValue:", areaValue); ReactDOM.render( diff --git a/examples/typescript-react-example/src/nested/Records.tsx b/examples/typescript-react-example/src/nested/Records.regen.tsx similarity index 100% rename from examples/typescript-react-example/src/nested/Records.tsx rename to examples/typescript-react-example/src/nested/Records.regen.tsx diff --git a/examples/typescript-react-example/src/nested/Tuples.tsx b/examples/typescript-react-example/src/nested/Tuples.regen.tsx similarity index 100% rename from examples/typescript-react-example/src/nested/Tuples.tsx rename to examples/typescript-react-example/src/nested/Tuples.regen.tsx diff --git a/examples/typescript-react-example/src/nested/Types.tsx b/examples/typescript-react-example/src/nested/Types.regen.tsx similarity index 100% rename from examples/typescript-react-example/src/nested/Types.tsx rename to examples/typescript-react-example/src/nested/Types.regen.tsx diff --git a/examples/untyped-react-example/bsconfig.json b/examples/untyped-react-example/bsconfig.json index b1cd7f8f8..0e7213b2f 100644 --- a/examples/untyped-react-example/bsconfig.json +++ b/examples/untyped-react-example/bsconfig.json @@ -3,9 +3,9 @@ "language": "untyped", "shims": {}, "debug": { - "all": false, - "basic": false - } + "all": false + }, + "exportInterfaces": false }, "name": "reason-react-example", "bsc-flags": ["-bs-super-errors"], diff --git a/examples/untyped-react-example/clean.js b/examples/untyped-react-example/clean.js new file mode 100644 index 000000000..718fe2fb7 --- /dev/null +++ b/examples/untyped-react-example/clean.js @@ -0,0 +1,18 @@ +const glob = require("glob"); +const fs = require("fs"); +const child_process = require("child_process"); + +glob.glob("src/**/*.bs.js", function(er, files) { + files.forEach(fileBsJs => { + const fileTsx = fileBsJs.substring(0, fileBsJs.length - 6) + "regen.js"; + fs.unlink(fileTsx, err => { + return; + }); + }); +}); + +const isWindows = /^win/i.test(process.platform); + +child_process + .spawn("bsb", ["-clean-world"], { stdio: "inherit", stderr: "inherit", shell: isWindows }) + .on("exit", code => process.exit(code)); diff --git a/examples/untyped-react-example/package-lock.json b/examples/untyped-react-example/package-lock.json index 2a9d1cae7..ac97b41c1 100644 --- a/examples/untyped-react-example/package-lock.json +++ b/examples/untyped-react-example/package-lock.json @@ -1217,7 +1217,8 @@ "big.js": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/big.js/-/big.js-3.2.0.tgz", - "integrity": "sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q==" + "integrity": "sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q==", + "dev": true }, "binary-extensions": { "version": "1.11.0", @@ -1936,7 +1937,8 @@ "emojis-list": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", - "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=" + "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=", + "dev": true }, "encoding": { "version": "0.1.12", @@ -2147,14 +2149,6 @@ } } }, - "extension-replace-loader": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/extension-replace-loader/-/extension-replace-loader-0.0.1.tgz", - "integrity": "sha1-nfqEf2vdlMyc8Rq3IizFEil6aI4=", - "requires": { - "loader-utils": "^0.2.14" - } - }, "extglob": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", @@ -3479,7 +3473,8 @@ "json5": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", - "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=" + "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", + "dev": true }, "kind-of": { "version": "6.0.2", @@ -3514,17 +3509,6 @@ "integrity": "sha1-9IKuqC1UPgeSFwDVpG7yb9rGuKI=", "dev": true }, - "loader-utils": { - "version": "0.2.17", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-0.2.17.tgz", - "integrity": "sha1-+G5jdNQyBabmxg6RlvF8Apm/s0g=", - "requires": { - "big.js": "^3.1.3", - "emojis-list": "^2.0.0", - "json5": "^0.5.0", - "object-assign": "^4.0.1" - } - }, "locate-path": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", diff --git a/examples/untyped-react-example/package.json b/examples/untyped-react-example/package.json index 6a86b0a1e..df1a8bd21 100644 --- a/examples/untyped-react-example/package.json +++ b/examples/untyped-react-example/package.json @@ -7,7 +7,7 @@ "scripts": { "build": "node ../run_bsb.js -make-world", "start": "node ../run_bsb.js -make-world -w", - "clean": "bsb -clean-world", + "clean": "node clean.js", "test": "exit 0", "webpack": "webpack -w", "webpack:production": "webpack --env.NODE_ENV=production" @@ -16,7 +16,6 @@ "author": "", "license": "MIT", "dependencies": { - "extension-replace-loader": "^0.0.1", "react": "^15.4.2", "react-dom": "^15.4.2", "reason-react": "^0.5.3" diff --git a/examples/untyped-react-example/src/App.re.js b/examples/untyped-react-example/src/App.regen.js similarity index 100% rename from examples/untyped-react-example/src/App.re.js rename to examples/untyped-react-example/src/App.regen.js diff --git a/examples/untyped-react-example/src/main.js b/examples/untyped-react-example/src/main.js index 00972dd34..902bb910a 100644 --- a/examples/untyped-react-example/src/main.js +++ b/examples/untyped-react-example/src/main.js @@ -1,7 +1,7 @@ const ReactDOM = require("react-dom"); const React = require("react"); -const App = require("./App.re").default; +const App = require("./App.regen").default; const Main = () => (
diff --git a/examples/untyped-react-example/webpack.config.js b/examples/untyped-react-example/webpack.config.js index db202133e..688da1655 100644 --- a/examples/untyped-react-example/webpack.config.js +++ b/examples/untyped-react-example/webpack.config.js @@ -25,12 +25,6 @@ module.exports = { ] } } - }, - { - loader: "extension-replace-loader", - query: { - exts: [{ from: ".re", to: ".re.js" }] - } } ] } diff --git a/src/EmitTyp.re b/src/EmitTyp.re index 7a4d0c5ec..d2c13ff15 100644 --- a/src/EmitTyp.re +++ b/src/EmitTyp.re @@ -17,12 +17,7 @@ let fileHeader = (~config) => let generatedFilesExtension = (~config) => switch (config.generatedFileExtension) { | Some(s) => s - | None => - switch (config.language) { - | Flow - | Untyped => ".re" - | TypeScript => "" - } + | None => ".regen" }; let outputFileSuffix = (~config) => @@ -32,8 +27,7 @@ let outputFileSuffix = (~config) => | TypeScript => generatedFilesExtension(~config) ++ ".tsx" }; -let generatedModuleExtension = (~config) => - generatedFilesExtension(~config); +let generatedModuleExtension = (~config) => generatedFilesExtension(~config); let shimExtension = (~config) => switch (config.language) { From 22878addb6e2093541bdb8b60b3d39eb81007626 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Thu, 8 Nov 2018 17:17:29 +0100 Subject: [PATCH 2/4] Change extension from .regen to .gen. --- README.md | 4 ++-- examples/reason-react-example/clean.js | 2 +- ...ules.regen.js => FirstClassModules.gen.js} | 0 .../src/{Marcel.regen.js => Marcel.gen.js} | 0 .../src/{Marcel1.regen.js => Marcel1.gen.js} | 0 .../src/{Marcel2.regen.js => Marcel2.gen.js} | 0 .../src/{Marcel3.regen.js => Marcel3.gen.js} | 0 .../src/{Marcel4.regen.js => Marcel4.gen.js} | 0 .../src/{Opaque.regen.js => Opaque.gen.js} | 0 ...ray.regen.js => TestImmutableArray.gen.js} | 0 ...xpansion.regen.js => TypeExpansion.gen.js} | 2 +- ...{Component1.regen.js => Component1.gen.js} | 2 +- ...{Component2.regen.js => Component2.gen.js} | 0 ...{Component3.regen.js => Component3.gen.js} | 0 .../basics/{Enums.regen.js => Enums.gen.js} | 0 .../{Records.regen.js => Records.gen.js} | 2 +- .../src/basics/SomeFlowTypes.js | 2 +- ...trictLocal.regen.js => StrictLocal.gen.js} | 0 .../basics/{Tuples.regen.js => Tuples.gen.js} | 0 .../basics/{Types.regen.js => Types.gen.js} | 0 .../reason-react-example/src/basics/Types.re | 2 +- .../src/basics/UseStrictLocalFromStrict.js | 2 +- ...ponents.regen.js => ManyComponents.gen.js} | 0 .../{Navigator.regen.js => Navigator.gen.js} | 0 ...enameProps.regen.js => RenameProps.gen.js} | 0 .../{Greeting.regen.js => Greeting.gen.js} | 0 .../src/interop/InteropRoot.js | 8 ++++---- .../src/interop/MyBannerWrapper.bs.js | 6 +++--- ...rapper.regen.js => MyBannerWrapper.gen.js} | 0 .../src/interop/MyBannerWrapper.re | 2 +- .../src/interop/MyMath.js | 2 +- .../src/interop/WrapJsValue.bs.js | 8 ++++---- ...rapJsValue.regen.js => WrapJsValue.gen.js} | 0 .../src/interop/WrapJsValue.re | 8 ++++---- .../nested/{Nested.regen.js => Nested.gen.js} | 2 +- examples/typescript-react-example/clean.js | 2 +- .../src/{Enums.regen.tsx => Enums.gen.tsx} | 0 ...es.regen.tsx => FirstClassModules.gen.tsx} | 0 .../src/MyBannerWrapper.bs.js | 6 +++--- ...pper.regen.tsx => MyBannerWrapper.gen.tsx} | 0 .../src/MyBannerWrapper.re | 2 +- ...odules.regen.tsx => NestedModules.gen.tsx} | 0 ...n.tsx => NestedModulesInSignature.gen.tsx} | 0 ...nent.regen.tsx => ReasonComponent.gen.tsx} | 4 ++-- ...y.regen.tsx => TestImmutableArray.gen.tsx} | 0 ...Value.regen.tsx => UseWrapJsValue.gen.tsx} | 4 ++-- .../src/WrapJsValue.bs.js | 6 +++--- ...pJsValue.regen.tsx => WrapJsValue.gen.tsx} | 0 .../src/WrapJsValue.re | 4 ++-- ...nents.regen.tsx => ManyComponents.gen.tsx} | 0 .../typescript-react-example/src/index.tsx | 20 +++++++++---------- .../{Records.regen.tsx => Records.gen.tsx} | 0 .../{Tuples.regen.tsx => Tuples.gen.tsx} | 0 .../nested/{Types.regen.tsx => Types.gen.tsx} | 0 examples/untyped-react-example/clean.js | 2 +- .../src/{App.regen.js => App.gen.js} | 0 examples/untyped-react-example/src/main.js | 2 +- src/EmitTyp.re | 2 +- 58 files changed, 54 insertions(+), 54 deletions(-) rename examples/reason-react-example/src/{FirstClassModules.regen.js => FirstClassModules.gen.js} (100%) rename examples/reason-react-example/src/{Marcel.regen.js => Marcel.gen.js} (100%) rename examples/reason-react-example/src/{Marcel1.regen.js => Marcel1.gen.js} (100%) rename examples/reason-react-example/src/{Marcel2.regen.js => Marcel2.gen.js} (100%) rename examples/reason-react-example/src/{Marcel3.regen.js => Marcel3.gen.js} (100%) rename examples/reason-react-example/src/{Marcel4.regen.js => Marcel4.gen.js} (100%) rename examples/reason-react-example/src/{Opaque.regen.js => Opaque.gen.js} (100%) rename examples/reason-react-example/src/{TestImmutableArray.regen.js => TestImmutableArray.gen.js} (100%) rename examples/reason-react-example/src/{TypeExpansion.regen.js => TypeExpansion.gen.js} (98%) rename examples/reason-react-example/src/basics/{Component1.regen.js => Component1.gen.js} (94%) rename examples/reason-react-example/src/basics/{Component2.regen.js => Component2.gen.js} (100%) rename examples/reason-react-example/src/basics/{Component3.regen.js => Component3.gen.js} (100%) rename examples/reason-react-example/src/basics/{Enums.regen.js => Enums.gen.js} (100%) rename examples/reason-react-example/src/basics/{Records.regen.js => Records.gen.js} (97%) rename examples/reason-react-example/src/basics/{StrictLocal.regen.js => StrictLocal.gen.js} (100%) rename examples/reason-react-example/src/basics/{Tuples.regen.js => Tuples.gen.js} (100%) rename examples/reason-react-example/src/basics/{Types.regen.js => Types.gen.js} (100%) rename examples/reason-react-example/src/components/{ManyComponents.regen.js => ManyComponents.gen.js} (100%) rename examples/reason-react-example/src/components/{Navigator.regen.js => Navigator.gen.js} (100%) rename examples/reason-react-example/src/components/{RenameProps.regen.js => RenameProps.gen.js} (100%) rename examples/reason-react-example/src/interop/{Greeting.regen.js => Greeting.gen.js} (100%) rename examples/reason-react-example/src/interop/{MyBannerWrapper.regen.js => MyBannerWrapper.gen.js} (100%) rename examples/reason-react-example/src/interop/{WrapJsValue.regen.js => WrapJsValue.gen.js} (100%) rename examples/reason-react-example/src/nested/{Nested.regen.js => Nested.gen.js} (97%) rename examples/typescript-react-example/src/{Enums.regen.tsx => Enums.gen.tsx} (100%) rename examples/typescript-react-example/src/{FirstClassModules.regen.tsx => FirstClassModules.gen.tsx} (100%) rename examples/typescript-react-example/src/{MyBannerWrapper.regen.tsx => MyBannerWrapper.gen.tsx} (100%) rename examples/typescript-react-example/src/{NestedModules.regen.tsx => NestedModules.gen.tsx} (100%) rename examples/typescript-react-example/src/{NestedModulesInSignature.regen.tsx => NestedModulesInSignature.gen.tsx} (100%) rename examples/typescript-react-example/src/{ReasonComponent.regen.tsx => ReasonComponent.gen.tsx} (95%) rename examples/typescript-react-example/src/{TestImmutableArray.regen.tsx => TestImmutableArray.gen.tsx} (100%) rename examples/typescript-react-example/src/{UseWrapJsValue.regen.tsx => UseWrapJsValue.gen.tsx} (93%) rename examples/typescript-react-example/src/{WrapJsValue.regen.tsx => WrapJsValue.gen.tsx} (100%) rename examples/typescript-react-example/src/components/{ManyComponents.regen.tsx => ManyComponents.gen.tsx} (100%) rename examples/typescript-react-example/src/nested/{Records.regen.tsx => Records.gen.tsx} (100%) rename examples/typescript-react-example/src/nested/{Tuples.regen.tsx => Tuples.gen.tsx} (100%) rename examples/typescript-react-example/src/nested/{Types.regen.tsx => Types.gen.tsx} (100%) rename examples/untyped-react-example/src/{App.regen.js => App.gen.js} (100%) diff --git a/README.md b/README.md index 32779cbf6..346554362 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,7 @@ To import a function `realValue` from JS module `MyMath.ts` (or `MyMath.js`): ```reason [@genType.import "./MyMath"] /* This is the module to import from. */ -[@bs.module "./WrapJsValue.regen"] /* Always the name of the current file. */ +[@bs.module "./WrapJsValue.gen"] /* Always the name of the current file. */ /* Name and type of the JS value to import. */ external realValue: complexNumber => float = ""; @@ -149,7 +149,7 @@ To import and wrap a ReactJS component for use by ReasonReact, the type of the ` ```reason [@genType.import "./MyBanner"] /* Module with the JS component to be wrapped. */ -[@bs.module "./MyBannerWrapper.regen"] /* Always the name of the current file. */ +[@bs.module "./MyBannerWrapper.gen"] /* Always the name of the current file. */ /* The make function will be automatically generated from the types below. */ external make: (~show: bool, ~message: option(message)=?, 'a) => diff --git a/examples/reason-react-example/clean.js b/examples/reason-react-example/clean.js index 718fe2fb7..6daa9b73d 100644 --- a/examples/reason-react-example/clean.js +++ b/examples/reason-react-example/clean.js @@ -4,7 +4,7 @@ const child_process = require("child_process"); glob.glob("src/**/*.bs.js", function(er, files) { files.forEach(fileBsJs => { - const fileTsx = fileBsJs.substring(0, fileBsJs.length - 6) + "regen.js"; + const fileTsx = fileBsJs.substring(0, fileBsJs.length - 6) + ".gen.js"; fs.unlink(fileTsx, err => { return; }); diff --git a/examples/reason-react-example/src/FirstClassModules.regen.js b/examples/reason-react-example/src/FirstClassModules.gen.js similarity index 100% rename from examples/reason-react-example/src/FirstClassModules.regen.js rename to examples/reason-react-example/src/FirstClassModules.gen.js diff --git a/examples/reason-react-example/src/Marcel.regen.js b/examples/reason-react-example/src/Marcel.gen.js similarity index 100% rename from examples/reason-react-example/src/Marcel.regen.js rename to examples/reason-react-example/src/Marcel.gen.js diff --git a/examples/reason-react-example/src/Marcel1.regen.js b/examples/reason-react-example/src/Marcel1.gen.js similarity index 100% rename from examples/reason-react-example/src/Marcel1.regen.js rename to examples/reason-react-example/src/Marcel1.gen.js diff --git a/examples/reason-react-example/src/Marcel2.regen.js b/examples/reason-react-example/src/Marcel2.gen.js similarity index 100% rename from examples/reason-react-example/src/Marcel2.regen.js rename to examples/reason-react-example/src/Marcel2.gen.js diff --git a/examples/reason-react-example/src/Marcel3.regen.js b/examples/reason-react-example/src/Marcel3.gen.js similarity index 100% rename from examples/reason-react-example/src/Marcel3.regen.js rename to examples/reason-react-example/src/Marcel3.gen.js diff --git a/examples/reason-react-example/src/Marcel4.regen.js b/examples/reason-react-example/src/Marcel4.gen.js similarity index 100% rename from examples/reason-react-example/src/Marcel4.regen.js rename to examples/reason-react-example/src/Marcel4.gen.js diff --git a/examples/reason-react-example/src/Opaque.regen.js b/examples/reason-react-example/src/Opaque.gen.js similarity index 100% rename from examples/reason-react-example/src/Opaque.regen.js rename to examples/reason-react-example/src/Opaque.gen.js diff --git a/examples/reason-react-example/src/TestImmutableArray.regen.js b/examples/reason-react-example/src/TestImmutableArray.gen.js similarity index 100% rename from examples/reason-react-example/src/TestImmutableArray.regen.js rename to examples/reason-react-example/src/TestImmutableArray.gen.js diff --git a/examples/reason-react-example/src/TypeExpansion.regen.js b/examples/reason-react-example/src/TypeExpansion.gen.js similarity index 98% rename from examples/reason-react-example/src/TypeExpansion.regen.js rename to examples/reason-react-example/src/TypeExpansion.gen.js index 36a89afd3..45e947b1d 100644 --- a/examples/reason-react-example/src/TypeExpansion.regen.js +++ b/examples/reason-react-example/src/TypeExpansion.gen.js @@ -7,7 +7,7 @@ // $FlowExpectedError: Reason checked type sufficiently const TypeExpansionBS = require('./TypeExpansion.bs'); -import type {person as Tuples_person} from '../src/basics/Tuples.regen'; +import type {person as Tuples_person} from '../src/basics/Tuples.gen'; export type personFromTuples = Tuples_person; diff --git a/examples/reason-react-example/src/basics/Component1.regen.js b/examples/reason-react-example/src/basics/Component1.gen.js similarity index 94% rename from examples/reason-react-example/src/basics/Component1.regen.js rename to examples/reason-react-example/src/basics/Component1.gen.js index b3ca0604b..ac85c1a0a 100644 --- a/examples/reason-react-example/src/basics/Component1.regen.js +++ b/examples/reason-react-example/src/basics/Component1.gen.js @@ -15,7 +15,7 @@ const ReasonReact = require('reason-react/src/ReasonReact.js'); import type {list} from '../../src/shims/ReasonPervasives.shim'; -import type {variant as Component2_variant} from './Component2.regen'; +import type {variant as Component2_variant} from './Component2.gen'; export type Props = {|+message?: string, +children?: mixed|}; diff --git a/examples/reason-react-example/src/basics/Component2.regen.js b/examples/reason-react-example/src/basics/Component2.gen.js similarity index 100% rename from examples/reason-react-example/src/basics/Component2.regen.js rename to examples/reason-react-example/src/basics/Component2.gen.js diff --git a/examples/reason-react-example/src/basics/Component3.regen.js b/examples/reason-react-example/src/basics/Component3.gen.js similarity index 100% rename from examples/reason-react-example/src/basics/Component3.regen.js rename to examples/reason-react-example/src/basics/Component3.gen.js diff --git a/examples/reason-react-example/src/basics/Enums.regen.js b/examples/reason-react-example/src/basics/Enums.gen.js similarity index 100% rename from examples/reason-react-example/src/basics/Enums.regen.js rename to examples/reason-react-example/src/basics/Enums.gen.js diff --git a/examples/reason-react-example/src/basics/Records.regen.js b/examples/reason-react-example/src/basics/Records.gen.js similarity index 97% rename from examples/reason-react-example/src/basics/Records.regen.js rename to examples/reason-react-example/src/basics/Records.gen.js index af39da082..7105cf41d 100644 --- a/examples/reason-react-example/src/basics/Records.regen.js +++ b/examples/reason-react-example/src/basics/Records.gen.js @@ -7,7 +7,7 @@ // $FlowExpectedError: Reason checked type sufficiently const RecordsBS = require('./Records.bs'); -import type {weekday as Types_weekday} from './Types.regen'; +import type {weekday as Types_weekday} from './Types.gen'; export type coord = {| +x: number, diff --git a/examples/reason-react-example/src/basics/SomeFlowTypes.js b/examples/reason-react-example/src/basics/SomeFlowTypes.js index b21fd527f..d5b6fb910 100644 --- a/examples/reason-react-example/src/basics/SomeFlowTypes.js +++ b/examples/reason-react-example/src/basics/SomeFlowTypes.js @@ -1,6 +1,6 @@ /* @flow strict */ -const Types = require("./Types.regen"); +const Types = require("./Types.gen"); export type anInterestingFlowType = { an: string, diff --git a/examples/reason-react-example/src/basics/StrictLocal.regen.js b/examples/reason-react-example/src/basics/StrictLocal.gen.js similarity index 100% rename from examples/reason-react-example/src/basics/StrictLocal.regen.js rename to examples/reason-react-example/src/basics/StrictLocal.gen.js diff --git a/examples/reason-react-example/src/basics/Tuples.regen.js b/examples/reason-react-example/src/basics/Tuples.gen.js similarity index 100% rename from examples/reason-react-example/src/basics/Tuples.regen.js rename to examples/reason-react-example/src/basics/Tuples.gen.js diff --git a/examples/reason-react-example/src/basics/Types.regen.js b/examples/reason-react-example/src/basics/Types.gen.js similarity index 100% rename from examples/reason-react-example/src/basics/Types.regen.js rename to examples/reason-react-example/src/basics/Types.gen.js diff --git a/examples/reason-react-example/src/basics/Types.re b/examples/reason-react-example/src/basics/Types.re index c4e3100e3..8a4a68924 100644 --- a/examples/reason-react-example/src/basics/Types.re +++ b/examples/reason-react-example/src/basics/Types.re @@ -75,7 +75,7 @@ type someMutableFields = { [@bs.set] "mutable2": string, }; -[@genType.import "./name-with-dashes"] [@bs.module "./Types.regen"] +[@genType.import "./name-with-dashes"] [@bs.module "./Types.gen"] external foo: int => int = ""; [@genType.opaque] diff --git a/examples/reason-react-example/src/basics/UseStrictLocalFromStrict.js b/examples/reason-react-example/src/basics/UseStrictLocalFromStrict.js index 6d96769a6..7d86a38ba 100644 --- a/examples/reason-react-example/src/basics/UseStrictLocalFromStrict.js +++ b/examples/reason-react-example/src/basics/UseStrictLocalFromStrict.js @@ -1,3 +1,3 @@ /* @flow strict */ -import type {someNonStrictType} from './StrictLocal.regen'; +import type {someNonStrictType} from './StrictLocal.gen'; diff --git a/examples/reason-react-example/src/components/ManyComponents.regen.js b/examples/reason-react-example/src/components/ManyComponents.gen.js similarity index 100% rename from examples/reason-react-example/src/components/ManyComponents.regen.js rename to examples/reason-react-example/src/components/ManyComponents.gen.js diff --git a/examples/reason-react-example/src/components/Navigator.regen.js b/examples/reason-react-example/src/components/Navigator.gen.js similarity index 100% rename from examples/reason-react-example/src/components/Navigator.regen.js rename to examples/reason-react-example/src/components/Navigator.gen.js diff --git a/examples/reason-react-example/src/components/RenameProps.regen.js b/examples/reason-react-example/src/components/RenameProps.gen.js similarity index 100% rename from examples/reason-react-example/src/components/RenameProps.regen.js rename to examples/reason-react-example/src/components/RenameProps.gen.js diff --git a/examples/reason-react-example/src/interop/Greeting.regen.js b/examples/reason-react-example/src/interop/Greeting.gen.js similarity index 100% rename from examples/reason-react-example/src/interop/Greeting.regen.js rename to examples/reason-react-example/src/interop/Greeting.gen.js diff --git a/examples/reason-react-example/src/interop/InteropRoot.js b/examples/reason-react-example/src/interop/InteropRoot.js index b4e8c843c..cd18ae724 100644 --- a/examples/reason-react-example/src/interop/InteropRoot.js +++ b/examples/reason-react-example/src/interop/InteropRoot.js @@ -3,10 +3,10 @@ const ReactDOM = require("react-dom"); const React = require("react"); -const GreetingRe = require("./Greeting.regen"); +const GreetingRe = require("./Greeting.gen"); // Import a ReasonReact component! -const PageReason = require("./Greeting.regen").default; +const PageReason = require("./Greeting.gen").default; const consoleLog = console.log; @@ -19,7 +19,7 @@ const helloWorld = GreetingRe.concat("++", helloWorldList); const someNumber: number = GreetingRe.testDefaultArgs({ y: 10 }); -const WrapJsValue = require("./WrapJsValue.regen"); +const WrapJsValue = require("./WrapJsValue.gen"); consoleLog("interopRoot.js roundedNumber:", WrapJsValue.roundedNumber); consoleLog("interopRoot.js areaValue:", WrapJsValue.areaValue); @@ -34,7 +34,7 @@ consoleLog("interopRoot.js callMyAreaDirectly:", callMyAreaDirectly); consoleLog("anInterestingFlowType ", require("../basics/SomeFlowTypes").c); -const Enums = require("../basics/Enums.regen"); +const Enums = require("../basics/Enums.gen"); consoleLog("Enums: swap(sunday) =", Enums.swap("sunday")); consoleLog("Enums: fortytwoOK is", Enums.fortytwoOK); diff --git a/examples/reason-react-example/src/interop/MyBannerWrapper.bs.js b/examples/reason-react-example/src/interop/MyBannerWrapper.bs.js index 819859164..d682ec0f1 100644 --- a/examples/reason-react-example/src/interop/MyBannerWrapper.bs.js +++ b/examples/reason-react-example/src/interop/MyBannerWrapper.bs.js @@ -1,11 +1,11 @@ // Generated by BUCKLESCRIPT VERSION 4.0.7, PLEASE EDIT WITH CARE 'use strict'; -var MyBannerWrapperRegen = require("./MyBannerWrapper.regen"); +var MyBannerWrapperGen = require("./MyBannerWrapper.gen"); function make(prim, prim$1, prim$2) { - return MyBannerWrapperRegen.make(prim, prim$1, prim$2); + return MyBannerWrapperGen.make(prim, prim$1, prim$2); } exports.make = make; -/* ./MyBannerWrapper.regen Not a pure module */ +/* ./MyBannerWrapper.gen Not a pure module */ diff --git a/examples/reason-react-example/src/interop/MyBannerWrapper.regen.js b/examples/reason-react-example/src/interop/MyBannerWrapper.gen.js similarity index 100% rename from examples/reason-react-example/src/interop/MyBannerWrapper.regen.js rename to examples/reason-react-example/src/interop/MyBannerWrapper.gen.js diff --git a/examples/reason-react-example/src/interop/MyBannerWrapper.re b/examples/reason-react-example/src/interop/MyBannerWrapper.re index f9ddb3694..a2d2c1096 100644 --- a/examples/reason-react-example/src/interop/MyBannerWrapper.re +++ b/examples/reason-react-example/src/interop/MyBannerWrapper.re @@ -2,7 +2,7 @@ * Wrap component MyBanner to be used from Reason. */ [@genType.import "./MyBanner.component"] /* Module with the JS component to be wrapped. */ -[@bs.module "./MyBannerWrapper.regen"] /* This must always be the name of the current module. */ +[@bs.module "./MyBannerWrapper.gen"] /* This must always be the name of the current module. */ /* The make function will be automatically generated from the types below. */ external make: (~show: bool) => diff --git a/examples/reason-react-example/src/interop/MyMath.js b/examples/reason-react-example/src/interop/MyMath.js index 0cc7188ae..7009ac0fa 100644 --- a/examples/reason-react-example/src/interop/MyMath.js +++ b/examples/reason-react-example/src/interop/MyMath.js @@ -1,6 +1,6 @@ /* @flow strict */ -const WrapJsValue = require("./WrapJsValue.regen"); +const WrapJsValue = require("./WrapJsValue.gen"); export const round: number => number = Math.round; diff --git a/examples/reason-react-example/src/interop/WrapJsValue.bs.js b/examples/reason-react-example/src/interop/WrapJsValue.bs.js index 31dea3cc6..f350cb520 100644 --- a/examples/reason-react-example/src/interop/WrapJsValue.bs.js +++ b/examples/reason-react-example/src/interop/WrapJsValue.bs.js @@ -1,15 +1,15 @@ // Generated by BUCKLESCRIPT VERSION 4.0.7, PLEASE EDIT WITH CARE 'use strict'; -var WrapJsValueRegen = require("./WrapJsValue.regen"); +var WrapJsValueGen = require("./WrapJsValue.gen"); function myArea(prim) { - return WrapJsValueRegen.area(prim); + return WrapJsValueGen.area(prim); } -var roundedNumber = WrapJsValueRegen.round(1.8); +var roundedNumber = WrapJsValueGen.round(1.8); -var areaValue = WrapJsValueRegen.area(/* record */[ +var areaValue = WrapJsValueGen.area(/* record */[ /* x */3, /* y */undefined ]); diff --git a/examples/reason-react-example/src/interop/WrapJsValue.regen.js b/examples/reason-react-example/src/interop/WrapJsValue.gen.js similarity index 100% rename from examples/reason-react-example/src/interop/WrapJsValue.regen.js rename to examples/reason-react-example/src/interop/WrapJsValue.gen.js diff --git a/examples/reason-react-example/src/interop/WrapJsValue.re b/examples/reason-react-example/src/interop/WrapJsValue.re index 26725c3db..e78dfb875 100644 --- a/examples/reason-react-example/src/interop/WrapJsValue.re +++ b/examples/reason-react-example/src/interop/WrapJsValue.re @@ -2,7 +2,7 @@ * Wrap JS values to be used from Reason */ [@genType.import "./MyMath"] /* This is the module to import from. */ -[@bs.module "./WrapJsValue.regen"] /* This must always be the name of the current module. */ +[@bs.module "./WrapJsValue.gen"] /* This must always be the name of the current module. */ /* Name and type of the JS value to bind to. */ external round: float => float = ""; @@ -13,7 +13,7 @@ type point = { }; [@genType.import "./MyMath"] /* This is the module to import from. */ -[@bs.module "./WrapJsValue.regen"] /* This must always be the name of the current module. */ +[@bs.module "./WrapJsValue.gen"] /* This must always be the name of the current module. */ /* Name and type of the JS value to bind to. */ external area: point => int = ""; @@ -30,12 +30,12 @@ let areaValue = area({x: 3, y: None}); type myArray('a); [@genType.import "./MyMath"] /* This is the module to import from. */ -[@bs.module "./WrapJsValue.regen"] /* This must always be the name of the current module. */ +[@bs.module "./WrapJsValue.gen"] /* This must always be the name of the current module. */ /* Name and type of the JS value to bind to. */ external getValueAtIndex: (myArray(string), int) => string = ""; [@genType.import "./MyMath"] /* This is the module to import from. */ -[@bs.module "./WrapJsValue.regen"] /* This must always be the name of the current module. */ +[@bs.module "./WrapJsValue.gen"] /* This must always be the name of the current module. */ /* Name and type of the JS value to bind to. */ external functionWithRenamedArgument: string => [@genType.as "ArgRenamed"] ((~argToRename: string) => string) = diff --git a/examples/reason-react-example/src/nested/Nested.regen.js b/examples/reason-react-example/src/nested/Nested.gen.js similarity index 97% rename from examples/reason-react-example/src/nested/Nested.regen.js rename to examples/reason-react-example/src/nested/Nested.gen.js index a72c297cb..1e9c394f8 100644 --- a/examples/reason-react-example/src/nested/Nested.regen.js +++ b/examples/reason-react-example/src/nested/Nested.gen.js @@ -10,7 +10,7 @@ const CreateBucklescriptBlock = require('bs-platform/lib/js/block.js'); // $FlowExpectedError: Reason checked type sufficiently const NestedBS = require('./Nested.bs'); -import type {variant as Component2_variant} from '../../src/basics/Component2.regen'; +import type {variant as Component2_variant} from '../../src/basics/Component2.gen'; export opaque type VariantA = mixed; diff --git a/examples/typescript-react-example/clean.js b/examples/typescript-react-example/clean.js index 1ff3443cd..18b872a0f 100644 --- a/examples/typescript-react-example/clean.js +++ b/examples/typescript-react-example/clean.js @@ -4,7 +4,7 @@ const child_process = require("child_process"); glob.glob("src/**/*.bs.js", function(er, files) { files.forEach(fileBsJs => { - const fileTsx = fileBsJs.substring(0, fileBsJs.length - 6) + ".regen.tsx"; + const fileTsx = fileBsJs.substring(0, fileBsJs.length - 6) + ".gen.tsx"; fs.unlink(fileTsx, err => { return; }); diff --git a/examples/typescript-react-example/src/Enums.regen.tsx b/examples/typescript-react-example/src/Enums.gen.tsx similarity index 100% rename from examples/typescript-react-example/src/Enums.regen.tsx rename to examples/typescript-react-example/src/Enums.gen.tsx diff --git a/examples/typescript-react-example/src/FirstClassModules.regen.tsx b/examples/typescript-react-example/src/FirstClassModules.gen.tsx similarity index 100% rename from examples/typescript-react-example/src/FirstClassModules.regen.tsx rename to examples/typescript-react-example/src/FirstClassModules.gen.tsx diff --git a/examples/typescript-react-example/src/MyBannerWrapper.bs.js b/examples/typescript-react-example/src/MyBannerWrapper.bs.js index f92b1c191..a8a743188 100644 --- a/examples/typescript-react-example/src/MyBannerWrapper.bs.js +++ b/examples/typescript-react-example/src/MyBannerWrapper.bs.js @@ -2,11 +2,11 @@ 'use strict'; var Js_primitive = require("bs-platform/lib/js/js_primitive.js"); -var MyBannerWrapperRegen = require("./MyBannerWrapper.regen"); +var MyBannerWrapperGen = require("./MyBannerWrapper.gen"); function make(prim, prim$1, prim$2) { - return MyBannerWrapperRegen.make(prim, prim$1 !== undefined ? Js_primitive.valFromOption(prim$1) : undefined, prim$2); + return MyBannerWrapperGen.make(prim, prim$1 !== undefined ? Js_primitive.valFromOption(prim$1) : undefined, prim$2); } exports.make = make; -/* ./MyBannerWrapper.regen Not a pure module */ +/* ./MyBannerWrapper.gen Not a pure module */ diff --git a/examples/typescript-react-example/src/MyBannerWrapper.regen.tsx b/examples/typescript-react-example/src/MyBannerWrapper.gen.tsx similarity index 100% rename from examples/typescript-react-example/src/MyBannerWrapper.regen.tsx rename to examples/typescript-react-example/src/MyBannerWrapper.gen.tsx diff --git a/examples/typescript-react-example/src/MyBannerWrapper.re b/examples/typescript-react-example/src/MyBannerWrapper.re index daf825901..38cd427e2 100644 --- a/examples/typescript-react-example/src/MyBannerWrapper.re +++ b/examples/typescript-react-example/src/MyBannerWrapper.re @@ -6,7 +6,7 @@ type message = {text: string}; [@genType.import "./MyBanner"] /* Module with the JS component to be wrapped. */ -[@bs.module "./MyBannerWrapper.regen"] /* This must always be the name of the current module. */ +[@bs.module "./MyBannerWrapper.gen"] /* This must always be the name of the current module. */ /* The make function will be automatically generated from the types below. */ external make: (~show: bool, ~message: option(message)=?, 'a) => diff --git a/examples/typescript-react-example/src/NestedModules.regen.tsx b/examples/typescript-react-example/src/NestedModules.gen.tsx similarity index 100% rename from examples/typescript-react-example/src/NestedModules.regen.tsx rename to examples/typescript-react-example/src/NestedModules.gen.tsx diff --git a/examples/typescript-react-example/src/NestedModulesInSignature.regen.tsx b/examples/typescript-react-example/src/NestedModulesInSignature.gen.tsx similarity index 100% rename from examples/typescript-react-example/src/NestedModulesInSignature.regen.tsx rename to examples/typescript-react-example/src/NestedModulesInSignature.gen.tsx diff --git a/examples/typescript-react-example/src/ReasonComponent.regen.tsx b/examples/typescript-react-example/src/ReasonComponent.gen.tsx similarity index 95% rename from examples/typescript-react-example/src/ReasonComponent.regen.tsx rename to examples/typescript-react-example/src/ReasonComponent.gen.tsx index 4da16b371..feeba40af 100644 --- a/examples/typescript-react-example/src/ReasonComponent.regen.tsx +++ b/examples/typescript-react-example/src/ReasonComponent.gen.tsx @@ -14,11 +14,11 @@ const ReasonReact = require('reason-react/src/ReasonReact.js'); import {Mouse_t as ReactEvent_Mouse_t} from '../src/shims/ReactEvent.shim'; -import {coord as Records_coord} from '../src/nested/Records.regen'; +import {coord as Records_coord} from '../src/nested/Records.gen'; import {list} from '../src/shims/ReasonPervasives.shim'; -import {t as Types_t} from '../src/nested/Types.regen'; +import {t as Types_t} from '../src/nested/Types.gen'; // tslint:disable-next-line:interface-over-type-literal export type person = { diff --git a/examples/typescript-react-example/src/TestImmutableArray.regen.tsx b/examples/typescript-react-example/src/TestImmutableArray.gen.tsx similarity index 100% rename from examples/typescript-react-example/src/TestImmutableArray.regen.tsx rename to examples/typescript-react-example/src/TestImmutableArray.gen.tsx diff --git a/examples/typescript-react-example/src/UseWrapJsValue.regen.tsx b/examples/typescript-react-example/src/UseWrapJsValue.gen.tsx similarity index 93% rename from examples/typescript-react-example/src/UseWrapJsValue.regen.tsx rename to examples/typescript-react-example/src/UseWrapJsValue.gen.tsx index 6024a4880..281bde75e 100644 --- a/examples/typescript-react-example/src/UseWrapJsValue.regen.tsx +++ b/examples/typescript-react-example/src/UseWrapJsValue.gen.tsx @@ -3,9 +3,9 @@ // tslint:disable-next-line:no-var-requires const UseWrapJsValueBS = require('./UseWrapJsValue.bs'); -import {AbsoluteValue_t as WrapJsValue_AbsoluteValue_t} from './WrapJsValue.regen'; +import {AbsoluteValue_t as WrapJsValue_AbsoluteValue_t} from './WrapJsValue.gen'; -import {stringFunction as WrapJsValue_stringFunction} from './WrapJsValue.regen'; +import {stringFunction as WrapJsValue_stringFunction} from './WrapJsValue.gen'; export const useGetProp: (_1:WrapJsValue_AbsoluteValue_t) => number = UseWrapJsValueBS.useGetProp; diff --git a/examples/typescript-react-example/src/WrapJsValue.bs.js b/examples/typescript-react-example/src/WrapJsValue.bs.js index f704e92ea..5b0f763a7 100644 --- a/examples/typescript-react-example/src/WrapJsValue.bs.js +++ b/examples/typescript-react-example/src/WrapJsValue.bs.js @@ -1,11 +1,11 @@ // Generated by BUCKLESCRIPT VERSION 4.0.7, PLEASE EDIT WITH CARE 'use strict'; -var WrapJsValueRegen = require("./WrapJsValue.regen"); +var WrapJsValueGen = require("./WrapJsValue.gen"); -var roundedNumber = WrapJsValueRegen.round(1.8); +var roundedNumber = WrapJsValueGen.round(1.8); -var areaValue = WrapJsValueRegen.area(/* record */[ +var areaValue = WrapJsValueGen.area(/* record */[ /* x */3, /* y */undefined ]); diff --git a/examples/typescript-react-example/src/WrapJsValue.regen.tsx b/examples/typescript-react-example/src/WrapJsValue.gen.tsx similarity index 100% rename from examples/typescript-react-example/src/WrapJsValue.regen.tsx rename to examples/typescript-react-example/src/WrapJsValue.gen.tsx diff --git a/examples/typescript-react-example/src/WrapJsValue.re b/examples/typescript-react-example/src/WrapJsValue.re index abbaf2bb3..4f5940176 100644 --- a/examples/typescript-react-example/src/WrapJsValue.re +++ b/examples/typescript-react-example/src/WrapJsValue.re @@ -2,7 +2,7 @@ * Wrap JS values to be used from Reason */ [@genType.import "./MyMath"] /* This is the module to import from. */ -[@bs.module "./WrapJsValue.regen"] /* This must always be the name of the current module. */ +[@bs.module "./WrapJsValue.gen"] /* This must always be the name of the current module. */ /* Name and type of the JS value to bind to. */ external round: float => float = ""; @@ -13,7 +13,7 @@ type point = { }; [@genType.import "./MyMath"] /* This is the module to import from. */ -[@bs.module "./WrapJsValue.regen"] /* This must always be the name of the current module. */ +[@bs.module "./WrapJsValue.gen"] /* This must always be the name of the current module. */ /* Name and type of the JS value to bind to. */ external area: point => int = ""; diff --git a/examples/typescript-react-example/src/components/ManyComponents.regen.tsx b/examples/typescript-react-example/src/components/ManyComponents.gen.tsx similarity index 100% rename from examples/typescript-react-example/src/components/ManyComponents.regen.tsx rename to examples/typescript-react-example/src/components/ManyComponents.gen.tsx diff --git a/examples/typescript-react-example/src/index.tsx b/examples/typescript-react-example/src/index.tsx index 94310c03b..6fc2e8799 100644 --- a/examples/typescript-react-example/src/index.tsx +++ b/examples/typescript-react-example/src/index.tsx @@ -1,17 +1,17 @@ import * as React from "react"; import * as ReactDOM from "react-dom"; import App from "./App"; -import * as Enums from "./Enums.regen"; +import * as Enums from "./Enums.gen"; import "./index.css"; import * as MyMath from "./MyMath"; -import * as Records from "./nested/Records.regen"; -import * as Types from "./nested/Types.regen"; -import { Universe_Nested2_Nested3_nested3Value } from "./NestedModules.regen"; -import ReasonComponent from "./ReasonComponent.regen"; -import { A, B, minus, tToString } from "./ReasonComponent.regen"; -import { t, TA, TB } from "./ReasonComponent.regen"; +import * as Records from "./nested/Records.gen"; +import * as Types from "./nested/Types.gen"; +import { Universe_Nested2_Nested3_nested3Value } from "./NestedModules.gen"; +import ReasonComponent from "./ReasonComponent.gen"; +import { A, B, minus, tToString } from "./ReasonComponent.gen"; +import { t, TA, TB } from "./ReasonComponent.gen"; import registerServiceWorker from "./registerServiceWorker"; -import * as WrapJsValue from "./WrapJsValue.regen"; +import * as WrapJsValue from "./WrapJsValue.gen"; const minusOne: number = minus({ second: 1 }); @@ -37,9 +37,9 @@ const businesses = [ const addresses = Records.findAllAddresses(businesses); -import { roundedNumber } from "./WrapJsValue.regen"; +import { roundedNumber } from "./WrapJsValue.gen"; consoleLog("index.tsx roundedNumber:", roundedNumber); -import { areaValue } from "./WrapJsValue.regen"; +import { areaValue } from "./WrapJsValue.gen"; consoleLog("index.tsx areaValue:", areaValue); ReactDOM.render( diff --git a/examples/typescript-react-example/src/nested/Records.regen.tsx b/examples/typescript-react-example/src/nested/Records.gen.tsx similarity index 100% rename from examples/typescript-react-example/src/nested/Records.regen.tsx rename to examples/typescript-react-example/src/nested/Records.gen.tsx diff --git a/examples/typescript-react-example/src/nested/Tuples.regen.tsx b/examples/typescript-react-example/src/nested/Tuples.gen.tsx similarity index 100% rename from examples/typescript-react-example/src/nested/Tuples.regen.tsx rename to examples/typescript-react-example/src/nested/Tuples.gen.tsx diff --git a/examples/typescript-react-example/src/nested/Types.regen.tsx b/examples/typescript-react-example/src/nested/Types.gen.tsx similarity index 100% rename from examples/typescript-react-example/src/nested/Types.regen.tsx rename to examples/typescript-react-example/src/nested/Types.gen.tsx diff --git a/examples/untyped-react-example/clean.js b/examples/untyped-react-example/clean.js index 718fe2fb7..6daa9b73d 100644 --- a/examples/untyped-react-example/clean.js +++ b/examples/untyped-react-example/clean.js @@ -4,7 +4,7 @@ const child_process = require("child_process"); glob.glob("src/**/*.bs.js", function(er, files) { files.forEach(fileBsJs => { - const fileTsx = fileBsJs.substring(0, fileBsJs.length - 6) + "regen.js"; + const fileTsx = fileBsJs.substring(0, fileBsJs.length - 6) + ".gen.js"; fs.unlink(fileTsx, err => { return; }); diff --git a/examples/untyped-react-example/src/App.regen.js b/examples/untyped-react-example/src/App.gen.js similarity index 100% rename from examples/untyped-react-example/src/App.regen.js rename to examples/untyped-react-example/src/App.gen.js diff --git a/examples/untyped-react-example/src/main.js b/examples/untyped-react-example/src/main.js index 902bb910a..f4637561a 100644 --- a/examples/untyped-react-example/src/main.js +++ b/examples/untyped-react-example/src/main.js @@ -1,7 +1,7 @@ const ReactDOM = require("react-dom"); const React = require("react"); -const App = require("./App.regen").default; +const App = require("./App.gen").default; const Main = () => (
diff --git a/src/EmitTyp.re b/src/EmitTyp.re index d2c13ff15..e8bf01a56 100644 --- a/src/EmitTyp.re +++ b/src/EmitTyp.re @@ -17,7 +17,7 @@ let fileHeader = (~config) => let generatedFilesExtension = (~config) => switch (config.generatedFileExtension) { | Some(s) => s - | None => ".regen" + | None => ".gen" }; let outputFileSuffix = (~config) => From 198e83ea814308212d30f54a072864e7ca5cdf3e Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Thu, 8 Nov 2018 17:33:39 +0100 Subject: [PATCH 3/4] =?UTF-8?q?Update=20README=20taking=20into=20account?= =?UTF-8?q?=20the=20extension=20=E2=80=9C.gen=E2=80=9D.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 346554362..d63d6a0ea 100644 --- a/README.md +++ b/README.md @@ -70,9 +70,9 @@ Configure your shim files in your `"gentypeconfig"` in [`bsconfig.json`](example ## Testing the whole setup -Open any relevant `*.re` file and add `[@genType]` annotations to any bindings / values / functions to be used from JavaScript. If an annotated value uses a type, the type must be annotated too. See e.g. [Component1.re](examples/reason-react-example/src/basics/Component1.re). +Open any relevant `*.re` file and add `[@genType]` annotations to any bindings / values / functions to be used from JavaScript. If an annotated value uses a type, the type must be annotated too. See e.g. [ReasonComponent.re](examples/typescript-react-example/src/ReasonComponent.re). -Save the file and rebuild the project with BuckleScript. You should now see a `*.re.js` file with the same name (e.g. `MyComponent.re` -> `MyComponent.re.js`). +Save the file and rebuild the project with BuckleScript. You should now see a `*.gen.tsx` (for TypeScript, or `*.gen.js` for Flow) file with the same name (e.g. `MyComponent.re` -> `MyComponent.gen.tsx`). # Examples @@ -121,7 +121,7 @@ To import a function `realValue` from JS module `MyMath.ts` (or `MyMath.js`): ```reason [@genType.import "./MyMath"] /* This is the module to import from. */ -[@bs.module "./WrapJsValue.gen"] /* Always the name of the current file. */ +[@bs.module "./WrapJsValue.gen"] /* Always the name of the current file plus ".gen". */ /* Name and type of the JS value to import. */ external realValue: complexNumber => float = ""; @@ -129,7 +129,7 @@ external realValue: complexNumber => float = ""; Because of the `external` keyword, it's clear from context that this is an import, so you can also just use `@genType` and omit `.import`. -**NOTE** The argument of `@bs.module`must always be the name of the current file (In future, with compiler support, this could be automatically generated). +**NOTE** The argument of `@bs.module`must always be the name of the current file plus `.gen` (In future, this could be automatically generated). ### Export and Import React Components @@ -149,7 +149,7 @@ To import and wrap a ReactJS component for use by ReasonReact, the type of the ` ```reason [@genType.import "./MyBanner"] /* Module with the JS component to be wrapped. */ -[@bs.module "./MyBannerWrapper.gen"] /* Always the name of the current file. */ +[@bs.module "./MyBannerWrapper.gen"] /* Always the name of the current file plus ".gen". */ /* The make function will be automatically generated from the types below. */ external make: (~show: bool, ~message: option(message)=?, 'a) => @@ -163,6 +163,9 @@ external make: The type of `make` must have a named argument for each prop in the JS component. Optional props have option type. The `make` function will be generated by `genType`. +**NOTE** The argument of `@bs.module`must always be the name of the current file plus `.gen` (In future, this could be automatically generated). + + ### Type Expansion and @genType.opaque If an exported type `persons` references other types in its definition, those types are also exported by default, as long as they are defined in the same file: From d15c7c56631558d90e5ba4e43eefb52e9db5c3cb Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Thu, 8 Nov 2018 17:45:52 +0100 Subject: [PATCH 4/4] README: explain the breaking change and what to do. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index d63d6a0ea..d512cd88d 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,10 @@ The output of `genType` can be configured by using one of 3 back-ends: `untyped` # Project status. See [Changes.md](Changes.md) for a complete list of features, fixes, and changes for each release. +> **Breaking Change:** From version 1.0.0, the extension of generated files is `.gen.tsx` (and `.gen.js`) instead of `.tsx` (and `.re.js`). You might need to adjust the argument of `@bs.module` when importing values and components to reflect this. +Alternatively, to keep the old and now deprecated extensions, the extension of generated files is configurable by specifying `"generatedFileExtension"` in the `"gentypeconfig"` section of `bsconfig.json`. (The extension used in versions 0.XX.0 was `""` for TypeScript and `".re"` for Flow/Untyped). + + > **Disclaimer:** While most of the feature set is complete, the project is still growing and changing based on feedback. It is possible that the workflow will change in future. # Requirements