-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use esm for requiring default and deprecated features #18218
Changes from 1 commit
c0e484a
e2fd4b5
e2de50c
fedf1d4
15cdeaa
6a54e1a
222e218
b3d35e6
32695e2
63b9826
95892c8
9cd5c50
6c02e4e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,12 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const ts = require('./typescript'); | ||
|
||
const requireEsm = require('esm')(module); | ||
function getFeatures() { | ||
let fileName = 'packages/@ember/canary-features/index.ts'; | ||
let fileContents = fs.readFileSync(fileName).toString(); | ||
|
||
let sourceFile = ts.createSourceFile( | ||
fileName, | ||
fileContents, | ||
ts.ScriptTarget.ES2017, | ||
/*setParentNodes */ true | ||
const { default: features } = requireEsm( | ||
'../packages/@ember/canary-features/default-features.js' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could not use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the local require (e.g. starting with |
||
); | ||
|
||
let features; | ||
|
||
ts.forEachChild(sourceFile, processVariableDeclarations); | ||
|
||
function processVariableDeclarations(node) { | ||
if (node.kind === ts.SyntaxKind.VariableDeclaration && node.name.text === 'DEFAULT_FEATURES') { | ||
let featuresText = node.initializer.getFullText(); | ||
features = new Function(`return ${featuresText}`)(); | ||
return; | ||
} | ||
|
||
ts.forEachChild(node, processVariableDeclarations); | ||
} | ||
|
||
let featureName; | ||
|
||
if (process.env.BUILD_TYPE === 'alpha') { | ||
for (featureName in features) { | ||
if (features[featureName] === null) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
This list of features is used both at build time (by `broccoli/features.js`) | ||
and at runtime (by `@ember/canary-features`). | ||
|
||
The valid values are: | ||
|
||
- true - The feature is enabled at all times, and cannot be disabled. | ||
- false - The feature is disabled at all times, and cannot be enabled. | ||
- null - The feature is disabled by default, but can be enabled at runtime via `EmberENV`. | ||
*/ | ||
export default { | ||
EMBER_LIBRARIES_ISREGISTERED: null, | ||
EMBER_IMPROVED_INSTRUMENTATION: null, | ||
EMBER_MODULE_UNIFICATION: false, | ||
EMBER_METAL_TRACKED_PROPERTIES: true, | ||
EMBER_GLIMMER_FORWARD_MODIFIERS_WITH_SPLATTRIBUTES: true, | ||
EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS: true, | ||
EMBER_NATIVE_DECORATOR_SUPPORT: true, | ||
EMBER_GLIMMER_FN_HELPER: true, | ||
EMBER_CUSTOM_COMPONENT_ARG_PROXY: true, | ||
EMBER_FRAMEWORK_OBJECT_OWNER_ARGUMENT: true, | ||
EMBER_GLIMMER_SET_COMPONENT_TEMPLATE: null, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the deprecated features also relies upon this module; I can remove it and merge the deprecated features functionality with this new approach once I sort how the typescript particulars below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya, sounds good to me.